Zelda Classic Coverage Report


Directory: src/
File: src/zc/zc_sys.cpp
Date: 2022-12-04 20:55:19
Exec Total Coverage
Lines: 1196 3862 31.0%
Functions: 108 336 32.1%
Branches: 573 2740 20.9%

Line Branch Exec Source
1 //--------------------------------------------------------
2 // Zelda Classic
3 // by Jeremy Craner, 1999-2000
4 //
5 // zc_sys.cc
6 //
7 // System functions, input handlers, GUI stuff, etc.
8 // for Zelda Classic.
9 //
10 //--------------------------------------------------------
11
12 // to prevent <map> from generating errors
13 #define __GTHREAD_HIDE_WIN32API 1
14
15 #include "precompiled.h" //always first
16 7 #include "zc_sys.h"
17
18 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21 #include <math.h>
22 #include <map>
23 #include <filesystem>
24 #include <ctype.h>
25 #include <sstream>
26 #include "base/zc_alleg.h"
27 #include "gamedata.h"
28 #include "zc_init.h"
29 #include "init.h"
30 #include "replay.h"
31 #include "cheats.h"
32 #include "render.h"
33 #include "base/zc_math.h"
34 #include "base/zapp.h"
35
36 #ifdef ALLEGRO_DOS
37 #include <unistd.h>
38 #endif
39
40 #include "metadata/metadata.h"
41 #include "zelda.h"
42 #include "tiles.h"
43 #include "base/colors.h"
44 #include "pal.h"
45 #include "base/zsys.h"
46 #include "qst.h"
47 #include "zc_sys.h"
48 #include "play_midi.h"
49 #include "debug.h"
50 #include "jwin.h"
51 #include "base/jwinfsel.h"
52 #include "base/gui.h"
53 #include "midi.h"
54 #include "subscr.h"
55 #include "maps.h"
56 #include "sprite.h"
57 #include "guys.h"
58 #include "hero.h"
59 #include "title.h"
60 #include "particles.h"
61 #include "zconsole.h"
62 #include "ffscript.h"
63 #include "dialog/info.h"
64 #include "dialog/alert.h"
65 #include <fmt/format.h>
66
67 #ifdef __EMSCRIPTEN__
68 #include "base/emscripten_utils.h"
69 #endif
70
71 extern FFScript FFCore;
72 extern bool Playing;
73 int32_t sfx_voice[WAV_COUNT];
74 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c);
75 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c);
76
77 extern byte monochrome_console;
78
79 extern FONT *lfont;
80 extern HeroClass Hero;
81 extern FFScript FFCore;
82 extern ZModule zcm;
83 extern zcmodule moduledata;
84 extern sprite_list guys, items, Ewpns, Lwpns, Sitems, chainlinks, decorations;
85 extern particle_list particles;
86 extern int32_t loadlast;
87 extern word passive_subscreen_doscript;
88 extern bool passive_subscreen_waitdraw;
89 byte use_dwm_flush;
90 byte use_save_indicator;
91 byte midi_patch_fix;
92 bool midi_paused=false;
93 int32_t paused_midi_pos = 0;
94 byte midi_suspended = 0;
95 byte callback_switchin = 0;
96 byte zc_192b163_warp_compatibility;
97 char modulepath[2048];
98 byte epilepsyFlashReduction;
99 signed char pause_in_background_menu_init = 0;
100 byte pause_in_background = 0;
101
0/2
✗ Branch 0 not taken.
✗ Branch 1 not taken.
7 bool is_sys_pal = false;
102 extern PALETTE* hw_palette;
103 extern bool update_hw_pal;
104 extern const char* dmaplist(int32_t index, int32_t* list_size);
105
106
107 extern bool kb_typing_mode; //script only, for disbaling key presses affecting Hero, etc.
108 extern int32_t cheat_modifier_keys[4]; //two options each, default either control and either shift
109 //extern byte refresh_select_screen;
110 //extern movingblock mblock2; //mblock[4]?
111 //extern int32_t db;
112
113 static const char *ZC_str = "Zelda Classic";
114 extern char save_file_name[1024];
115 #ifdef ALLEGRO_DOS
116 const char *qst_dir_name = "dos_qst_dir";
117 #elif defined(ALLEGRO_WINDOWS)
118 const char *qst_dir_name = "win_qst_dir";
119 static const char *qst_module_name = "current_module";
120 #elif defined(ALLEGRO_LINUX)
121 const char *qst_dir_name = "linux_qst_dir";
122 static const char *qst_module_name = "current_module";
123 #elif defined(__APPLE__)
124 const char *qst_dir_name = "osx_qst_dir";
125 static const char *qst_module_name = "current_module";
126 #endif
127 #ifdef ALLEGRO_LINUX
128 static const char *samplepath = "samplesoundset/patches.dat";
129 #endif
130 char qst_files_path[2048];
131
132 #ifdef _MSC_VER
133 #define getcwd _getcwd
134 #endif
135
136 bool rF11();
137 bool rI();
138 bool rQ();
139 bool zc_key_pressed();
140
141 #ifdef _WIN32
142
143 // This should only be necessary for MinGW, since it doesn't have a dwmapi.h. Add another #ifdef if you like.
144 extern "C"
145 {
146 typedef HRESULT(WINAPI *t_DwmFlush)();
147 typedef HRESULT(WINAPI *t_DwmIsCompositionEnabled)(BOOL *pfEnabled);
148 }
149
150 void do_DwmFlush()
151 {
152 static HMODULE shell = LoadLibrary("dwmapi.dll");
153
154 if(!shell)
155 return;
156
157 static t_DwmFlush flush=reinterpret_cast<t_DwmFlush>(GetProcAddress(shell, "DwmFlush"));
158 static t_DwmIsCompositionEnabled isEnabled=reinterpret_cast<t_DwmIsCompositionEnabled>(GetProcAddress(shell, "DwmIsCompositionEnabled"));
159
160 BOOL enabled;
161 isEnabled(&enabled);
162
163 if(isEnabled)
164 flush();
165 }
166
167 #endif // _WIN32
168
169 // Dialogue largening
170 void large_dialog(DIALOG *d)
171 {
172 large_dialog(d, 1.5);
173 }
174
175 void large_dialog(DIALOG *d, float RESIZE_AMT)
176 {
177 if(!d[0].d1)
178 {
179 d[0].d1 = 1;
180 int32_t oldwidth = d[0].w;
181 int32_t oldheight = d[0].h;
182 int32_t oldx = d[0].x;
183 int32_t oldy = d[0].y;
184 d[0].x -= int32_t(d[0].w/RESIZE_AMT);
185 d[0].y -= int32_t(d[0].h/RESIZE_AMT);
186 d[0].w = int32_t(d[0].w*RESIZE_AMT);
187 d[0].h = int32_t(d[0].h*RESIZE_AMT);
188
189 for(int32_t i=1; d[i].proc !=NULL; i++)
190 {
191 // Place elements horizontally
192 double xpc = ((double)(d[i].x - oldx) / (double)oldwidth);
193 d[i].x = int32_t(d[0].x + (xpc*d[0].w));
194
195 if(d[i].proc != d_stringloader)
196 {
197 if(d[i].proc==d_bitmap_proc)
198 {
199 d[i].w *= 2;
200 }
201 else d[i].w = int32_t(d[i].w*RESIZE_AMT);
202 }
203
204 // Place elements vertically
205 double ypc = ((double)(d[i].y - oldy) / (double)oldheight);
206 d[i].y = int32_t(d[0].y + (ypc*d[0].h));
207
208 // Vertically resize elements
209 if(d[i].proc == jwin_edit_proc || d[i].proc == jwin_check_proc || d[i].proc == jwin_checkfont_proc)
210 {
211 d[i].h = int32_t((double)d[i].h*1.5);
212 }
213 else if(d[i].proc == jwin_droplist_proc)
214 {
215 d[i].y += int32_t((double)d[i].h*0.25);
216 d[i].h = int32_t((double)d[i].h*1.25);
217 }
218 else if(d[i].proc==d_bitmap_proc)
219 {
220 d[i].h *= 2;
221 }
222 else d[i].h = int32_t(d[i].h*RESIZE_AMT);
223
224 // Fix frames
225 if(d[i].proc == jwin_frame_proc)
226 {
227 d[i].x++;
228 d[i].y++;
229 d[i].w-=4;
230 d[i].h-=4;
231 }
232 }
233 }
234
235 for(int32_t i=1; d[i].proc!=NULL; i++)
236 {
237 if(d[i].proc==jwin_slider_proc)
238 continue;
239
240 // Bigger font
241 bool bigfontproc = (d[i].proc != d_midilist_proc && d[i].proc != jwin_droplist_proc && d[i].proc != jwin_abclist_proc && d[i].proc != jwin_list_proc);
242
243 if(!d[i].dp2 && bigfontproc)
244 {
245 //d[i].dp2 = (d[i].proc == jwin_edit_proc) ? sfont3 : lfont_l;
246 d[i].dp2 = lfont_l;
247 }
248 else if(!bigfontproc)
249 {
250 // ((ListData *)d[i].dp)->font = &sfont3;
251 ((ListData *)d[i].dp)->font = &lfont_l;
252 }
253
254 // Make checkboxes work
255 if(d[i].proc == jwin_check_proc)
256 d[i].proc = jwin_checkfont_proc;
257 else if(d[i].proc == jwin_radio_proc)
258 d[i].proc = jwin_radiofont_proc;
259 }
260
261 jwin_center_dialog(d);
262 }
263
264
265 /**********************************/
266 /******** System functions ********/
267 /**********************************/
268
269 static char cfg_sect[] = "zeldadx"; //We need to rename this.
270 static char ctrl_sect[] = "Controls";
271 static char sfx_sect[] = "Volume";
272
273 int32_t d_dummy_proc(int32_t,DIALOG *,int32_t)
274 {
275 return D_O_K;
276 }
277
278 7 void load_game_configs()
279 {
280 7 strcpy(moduledata.module_name,zc_get_config("ZCMODULE",qst_module_name,"classic.zmod"));
281 7 joystick_index = zc_get_config(ctrl_sect,"joystick_index",0);
282 7 js_stick_1_x_stick = zc_get_config(ctrl_sect,"js_stick_1_x_stick",0);
283 7 js_stick_1_x_axis = zc_get_config(ctrl_sect,"js_stick_1_x_axis",0);
284 7 js_stick_1_x_offset = zc_get_config(ctrl_sect,"js_stick_1_x_offset",0) ? 128 : 0;
285 7 js_stick_1_y_stick = zc_get_config(ctrl_sect,"js_stick_1_y_stick",0);
286 7 js_stick_1_y_axis = zc_get_config(ctrl_sect,"js_stick_1_y_axis",1);
287 7 js_stick_1_y_offset = zc_get_config(ctrl_sect,"js_stick_1_y_offset",0) ? 128 : 0;
288 7 js_stick_2_x_stick = zc_get_config(ctrl_sect,"js_stick_2_x_stick",1);
289 7 js_stick_2_x_axis = zc_get_config(ctrl_sect,"js_stick_2_x_axis",0);
290 7 js_stick_2_x_offset = zc_get_config(ctrl_sect,"js_stick_2_x_offset",0) ? 128 : 0;
291 7 js_stick_2_y_stick = zc_get_config(ctrl_sect,"js_stick_2_y_stick",1);
292 7 js_stick_2_y_axis = zc_get_config(ctrl_sect,"js_stick_2_y_axis",1);
293 7 js_stick_2_y_offset = zc_get_config(ctrl_sect,"js_stick_2_y_offset",0) ? 128 : 0;
294 7 analog_movement = (zc_get_config(ctrl_sect,"analog_movement",1));
295
296 //cheat modifier keya
297 7 cheat_modifier_keys[0] = zc_get_config(ctrl_sect,"key_cheatmod_a1",KEY_ZC_LCONTROL);
298 7 cheat_modifier_keys[1] = zc_get_config(ctrl_sect,"key_cheatmod_a2",0);
299 7 cheat_modifier_keys[2] = zc_get_config(ctrl_sect,"key_cheatmod_b1",KEY_ZC_RCONTROL);
300 7 cheat_modifier_keys[3] = zc_get_config(ctrl_sect,"key_cheatmod_b2",0);
301
302
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if((uint32_t)joystick_index >= MAX_JOYSTICKS)
303 joystick_index = 0;
304
305 7 Akey = zc_get_config(ctrl_sect,"key_a",KEY_Z);
306 7 Bkey = zc_get_config(ctrl_sect,"key_b",KEY_X);
307 7 Skey = zc_get_config(ctrl_sect,"key_s",KEY_ENTER);
308 7 Lkey = zc_get_config(ctrl_sect,"key_l",KEY_Q);
309 7 Rkey = zc_get_config(ctrl_sect,"key_r",KEY_W);
310 7 Pkey = zc_get_config(ctrl_sect,"key_p",KEY_SPACE);
311 7 Exkey1 = zc_get_config(ctrl_sect,"key_ex1",KEY_A);
312 7 Exkey2 = zc_get_config(ctrl_sect,"key_ex2",KEY_S);
313 7 Exkey3 = zc_get_config(ctrl_sect,"key_ex3",KEY_D);
314 7 Exkey4 = zc_get_config(ctrl_sect,"key_ex4",KEY_C);
315
316 7 DUkey = zc_get_config(ctrl_sect,"key_up", KEY_UP);
317 7 DDkey = zc_get_config(ctrl_sect,"key_down", KEY_DOWN);
318 7 DLkey = zc_get_config(ctrl_sect,"key_left", KEY_LEFT);
319 7 DRkey = zc_get_config(ctrl_sect,"key_right",KEY_RIGHT);
320
321 7 Abtn = zc_get_config(ctrl_sect,"btn_a",2);
322 7 Bbtn = zc_get_config(ctrl_sect,"btn_b",1);
323 7 Sbtn = zc_get_config(ctrl_sect,"btn_s",10);
324 7 Mbtn = zc_get_config(ctrl_sect,"btn_m",9);
325 7 Lbtn = zc_get_config(ctrl_sect,"btn_l",5);
326 7 Rbtn = zc_get_config(ctrl_sect,"btn_r",6);
327 7 Pbtn = zc_get_config(ctrl_sect,"btn_p",12);
328 7 Exbtn1 = zc_get_config(ctrl_sect,"btn_ex1",7);
329 7 Exbtn2 = zc_get_config(ctrl_sect,"btn_ex2",8);
330 7 Exbtn3 = zc_get_config(ctrl_sect,"btn_ex3",4);
331 7 Exbtn4 = zc_get_config(ctrl_sect,"btn_ex4",3);
332
333 7 DUbtn = zc_get_config(ctrl_sect,"btn_up",13);
334 7 DDbtn = zc_get_config(ctrl_sect,"btn_down",14);
335 7 DLbtn = zc_get_config(ctrl_sect,"btn_left",15);
336 7 DRbtn = zc_get_config(ctrl_sect,"btn_right",16);
337
338 7 epilepsyFlashReduction = zc_get_config(cfg_sect,"epilepsy_flash_reduction",0);
339
340 7 digi_volume = zc_get_config(sfx_sect,"digi",248);
341 7 midi_volume = zc_get_config(sfx_sect,"midi",255);
342 7 sfx_volume = zc_get_config(sfx_sect,"sfx",248);
343 7 emusic_volume = zc_get_config(sfx_sect,"emusic",248);
344 7 pan_style = zc_get_config(sfx_sect,"pan",1);
345 // 1 <= zcmusic_bufsz <= 128
346 7 zcmusic_bufsz = vbound(zc_get_config(sfx_sect,"zcmusic_bufsz",64),1,128);
347 7 volkeys = zc_get_config(sfx_sect,"volkeys",0)!=0;
348 7 zc_vsync = zc_get_config(cfg_sect,"vsync",0);
349 7 Throttlefps = zc_get_config(cfg_sect,"throttlefps",1)!=0;
350 7 TransLayers = zc_get_config(cfg_sect,"translayers",1)!=0;
351 7 SnapshotFormat = zc_get_config(cfg_sect,"snapshot_format",3);
352 7 NameEntryMode = zc_get_config(cfg_sect,"name_entry_mode",0);
353 #ifdef __EMSCRIPTEN__
354 if (em_is_mobile()) NameEntryMode = 2;
355 #endif
356 7 ShowFPS = zc_get_config(cfg_sect,"showfps",0)!=0;
357 7 NESquit = zc_get_config(cfg_sect,"fastquit",0)!=0;
358 7 ClickToFreeze = zc_get_config(cfg_sect,"clicktofreeze",1)!=0;
359 7 title_version = zc_get_config(cfg_sect,"title",2);
360 7 abc_patternmatch = zc_get_config(cfg_sect, "lister_pattern_matching", 1);
361 7 pause_in_background = zc_get_config(cfg_sect, "pause_in_background", 0);
362
363 //default - scale x2, 640 x 480
364 7 window_width = resx = zc_get_config(cfg_sect,"window_width",640);
365 7 window_height = resy = zc_get_config(cfg_sect,"window_height",480);
366 7 SaveDragResize = zc_get_config(cfg_sect,"save_drag_resize",0)!=0;
367 7 DragAspect = zc_get_config(cfg_sect,"drag_aspect",0)!=0;
368 7 SaveWinPos = zc_get_config(cfg_sect,"save_window_position",0)!=0;
369
370 7 loadlast = zc_get_config(cfg_sect,"load_last",0);
371
372 7 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
373
374 7 zc_color_depth = (byte) zc_get_config(cfg_sect,"color_depth",8);
375
376 //workaround for the 100% CPU bug. -Gleeok
377 #ifdef ALLEGRO_MACOSX //IIRC rest(0) was a mac issue fix.
378 7 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",0);
379 #else
380 frame_rest_suggest = (byte) zc_get_config(cfg_sect,"frame_rest_suggest",1);
381 #endif
382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 frame_rest_suggest = zc_min(2, frame_rest_suggest);
383
384 7 forceExit = (byte) zc_get_config(cfg_sect,"force_exit",0);
385
386 #ifdef _WIN32
387 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
388 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
389 //use_win7_keyboard_fix = (byte) zc_get_config(cfg_sect,"use_win7_key_fix",0);
390 use_win32_proc = (byte) zc_get_config(cfg_sect,"zc_win_proc_fix",0); //buggy
391
392 // This one's for Aero
393 use_dwm_flush = (byte) zc_get_config("zeldadx","use_dwm_flush",0);
394
395 // And this one fixes patches unloading on some MIDI setups
396 midi_patch_fix = (byte) zc_get_config("zeldadx","midi_patch_fix",1);
397 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
398 #else //UNIX
399 7 zasm_debugger = (byte) zc_get_config("CONSOLE","print_ZASM",0);
400 7 zscript_debugger = (byte) zc_get_config("CONSOLE","ZScript_Debugger",0);
401 7 monochrome_console = (byte) zc_get_config("CONSOLE","monochrome_debuggers",0);
402 #endif
403
404 7 char const* default_path = "";
405 7 strcpy(qstdir,zc_get_config(cfg_sect,qst_dir_name,default_path));
406
407
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(strlen(qstdir)==0)
408 {
409 7 getcwd(qstdir,2048);
410 7 fix_filename_case(qstdir);
411 7 fix_filename_slashes(qstdir);
412 7 put_backslash(qstdir);
413 7 }
414 else
415 {
416 chop_path(qstdir);
417 }
418
419 7 strcpy(qstpath,qstdir); //qstpath is the local (for this run of ZC) quest path, qstdir is the universal quest dir.
420 7 ss_enable = zc_get_config(cfg_sect,"ss_enable",1) ? 1 : 0;
421 7 ss_after = vbound(zc_get_config(cfg_sect,"ss_after",14), 0, 14);
422 7 ss_speed = vbound(zc_get_config(cfg_sect,"ss_speed",2), 0, 6);
423 7 ss_density = vbound(zc_get_config(cfg_sect,"ss_density",3), 0, 6);
424 7 heart_beep = zc_get_config(cfg_sect,"heart_beep",1)!=0;
425 7 gui_colorset = zc_get_config(cfg_sect,"gui_colorset",0);
426 7 sfxdat = zc_get_config(cfg_sect,"use_sfx_dat",1);
427 7 fullscreen = zc_get_config(cfg_sect,"fullscreen",0);
428 7 use_save_indicator = zc_get_config(cfg_sect,"save_indicator",0);
429 7 zc_192b163_warp_compatibility = zc_get_config(cfg_sect,"zc_192b163_warp_compatibility",0);
430 7 }
431
432 void save_control_configs(bool kb)
433 {
434 if(kb)
435 {
436 zc_set_config(ctrl_sect,"key_cheatmod_a1",cheat_modifier_keys[0]);
437 zc_set_config(ctrl_sect,"key_cheatmod_a2",cheat_modifier_keys[1]);
438 zc_set_config(ctrl_sect,"key_cheatmod_b1",cheat_modifier_keys[2]);
439 zc_set_config(ctrl_sect,"key_cheatmod_b2",cheat_modifier_keys[3]);
440
441 if (!replay_is_replaying())
442 {
443 zc_set_config(ctrl_sect,"key_a",Akey);
444 zc_set_config(ctrl_sect,"key_b",Bkey);
445 zc_set_config(ctrl_sect,"key_s",Skey);
446 zc_set_config(ctrl_sect,"key_l",Lkey);
447 zc_set_config(ctrl_sect,"key_r",Rkey);
448 zc_set_config(ctrl_sect,"key_p",Pkey);
449 zc_set_config(ctrl_sect,"key_ex1",Exkey1);
450 zc_set_config(ctrl_sect,"key_ex2",Exkey2);
451 zc_set_config(ctrl_sect,"key_ex3",Exkey3);
452 zc_set_config(ctrl_sect,"key_ex4",Exkey4);
453 zc_set_config(ctrl_sect,"key_up", DUkey);
454 zc_set_config(ctrl_sect,"key_down", DDkey);
455 zc_set_config(ctrl_sect,"key_left", DLkey);
456 zc_set_config(ctrl_sect,"key_right",DRkey);
457 }
458 }
459 else
460 {
461 zc_set_config(ctrl_sect,"joystick_index",joystick_index);
462 zc_set_config(ctrl_sect,"js_stick_1_x_stick",js_stick_1_x_stick);
463 zc_set_config(ctrl_sect,"js_stick_1_x_axis",js_stick_1_x_axis);
464 zc_set_config(ctrl_sect,"js_stick_1_x_offset",js_stick_1_x_offset ? 1 : 0);
465 zc_set_config(ctrl_sect,"js_stick_1_y_stick",js_stick_1_y_stick);
466 zc_set_config(ctrl_sect,"js_stick_1_y_axis",js_stick_1_y_axis);
467 zc_set_config(ctrl_sect,"js_stick_1_y_offset",js_stick_1_y_offset ? 1 : 0);
468 zc_set_config(ctrl_sect,"js_stick_2_x_stick",js_stick_2_x_stick);
469 zc_set_config(ctrl_sect,"js_stick_2_x_axis",js_stick_2_x_axis);
470 zc_set_config(ctrl_sect,"js_stick_2_x_offset",js_stick_2_x_offset ? 1 : 0);
471 zc_set_config(ctrl_sect,"js_stick_2_y_stick",js_stick_2_y_stick);
472 zc_set_config(ctrl_sect,"js_stick_2_y_axis",js_stick_2_y_axis);
473 zc_set_config(ctrl_sect,"js_stick_2_y_offset",js_stick_2_y_offset ? 1 : 0);
474 zc_set_config(ctrl_sect,"analog_movement",analog_movement);
475
476 zc_set_config(ctrl_sect,"btn_a",Abtn);
477 zc_set_config(ctrl_sect,"btn_b",Bbtn);
478 zc_set_config(ctrl_sect,"btn_s",Sbtn);
479 zc_set_config(ctrl_sect,"btn_m",Mbtn);
480 zc_set_config(ctrl_sect,"btn_l",Lbtn);
481 zc_set_config(ctrl_sect,"btn_r",Rbtn);
482 zc_set_config(ctrl_sect,"btn_p",Pbtn);
483 zc_set_config(ctrl_sect,"btn_ex1",Exbtn1);
484 zc_set_config(ctrl_sect,"btn_ex2",Exbtn2);
485 zc_set_config(ctrl_sect,"btn_ex3",Exbtn3);
486 zc_set_config(ctrl_sect,"btn_ex4",Exbtn4);
487
488 zc_set_config(ctrl_sect,"btn_up",DUbtn);
489 zc_set_config(ctrl_sect,"btn_down",DDbtn);
490 zc_set_config(ctrl_sect,"btn_left",DLbtn);
491 zc_set_config(ctrl_sect,"btn_right",DRbtn);
492 }
493 }
494
495 void save_game_configs()
496 {
497 packfile_password("");
498
499 zc_set_config("ZCMODULE",qst_module_name,moduledata.module_name);
500
501 if (all_get_display() && !all_get_fullscreen_flag()&& SaveWinPos)
502 {
503 int o_window_x, o_window_y;
504 al_get_window_position(all_get_display(), &o_window_x, &o_window_y);
505 zc_set_config(cfg_sect,"window_x",o_window_x);
506 zc_set_config(cfg_sect,"window_y",o_window_y);
507 }
508
509 if (all_get_display() && !all_get_fullscreen_flag() && SaveDragResize)
510 {
511 double monitor_scale = zc_get_monitor_scale();
512 window_width = al_get_display_width(all_get_display()) / monitor_scale;
513 window_height = al_get_display_height(all_get_display()) / monitor_scale;
514 zc_set_config(cfg_sect,"window_width",window_width);
515 zc_set_config(cfg_sect,"window_height",window_height);
516 }
517
518 zc_set_config(cfg_sect,"load_last",loadlast);
519 chop_path(qstdir);
520 zc_set_config(cfg_sect,qst_dir_name,qstdir);
521 zc_set_config("SAVEFILE","save_filename",save_file_name);
522 zc_set_config(cfg_sect,"use_sfx_dat",sfxdat);
523 zc_set_config(cfg_sect,"frame_rest_suggest",frame_rest_suggest);
524
525 flush_config_file();
526 #ifdef __EMSCRIPTEN__
527 em_sync_fs();
528 #endif
529 }
530
531 //----------------------------------------------------------------
532
533 // Timers
534
535 314 void fps_callback()
536 {
537 314 lastfps=framecnt;
538 314 dword tempsecs = fps_secs;
539 314 ++tempsecs;
540 //avgfps=((long double)avgfps*fps_secs+lastfps)/(++fps_secs); // DJGPP doesn't like this
541 314 avgfps=((long double)avgfps*fps_secs+lastfps)/(tempsecs);
542 314 ++fps_secs;
543 314 framecnt=0;
544 314 }
545
546 END_OF_FUNCTION(fps_callback)
547
548 7 int32_t Z_init_timers()
549 {
550 static bool didit = false;
551 const static char *err_str = "Couldn't allocate timer";
552 7 err_str = err_str; //Unused variable warning
553
554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(didit)
555 return 1;
556
557 7 didit = true;
558
559 LOCK_VARIABLE(lastfps);
560 LOCK_VARIABLE(framecnt);
561 LOCK_FUNCTION(fps_callback);
562
563
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(install_int_ex(fps_callback,SECS_TO_TIMER(1)))
564 return 0;
565
566 7 return 1;
567 7 }
568
569 void Z_remove_timers()
570 {
571 remove_int(fps_callback);
572 }
573
574 //----------------------------------------------------------------
575
576 void go()
577 {
578 scare_mouse();
579 blit(screen,tmp_scr,scrx,scry,0,0,screen->w,screen->h);
580 unscare_mouse();
581 }
582
583 void comeback()
584 {
585 scare_mouse();
586 blit(tmp_scr,screen,0,0,scrx,scry,screen->w,screen->h);
587 unscare_mouse();
588 }
589
590 void dump_pal(BITMAP *dest)
591 {
592 for(int32_t i=0; i<256; i++)
593 rectfill(dest,(i&63)<<2,(i&0xFC0)>>4,((i&63)<<2)+3,((i&0xFC0)>>4)+3,i);
594 }
595
596 //----------------------------------------------------------------
597
598 //Handles converting the mouse sprite from the .dat file
599 7 void load_mouse()
600 {
601 7 system_pal();
602 7 scare_mouse();
603 7 set_mouse_sprite(NULL);
604
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 int32_t sz = vbound(int32_t(16*(is_large ? zc_get_config("zeldadx","cursor_scale_large",1.5) : zc_get_config("zeldadx","cursor_scale_small",1))),16,80);
605
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
35 for(int32_t j = 0; j < 4; ++j)
606 {
607 28 BITMAP* tmpbmp = create_bitmap_ex(8,16,16);
608 28 BITMAP* subbmp = create_bitmap_ex(8,16,16);
609
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(zcmouse[j])
610 destroy_bitmap(zcmouse[j]);
611 28 zcmouse[j] = create_bitmap_ex(8,sz,sz);
612 28 clear_bitmap(zcmouse[j]);
613 28 clear_bitmap(tmpbmp);
614 28 clear_bitmap(subbmp);
615 28 blit((BITMAP*)datafile[BMP_MOUSE].dat,tmpbmp,1,j*17+1,0,0,16,16);
616
2/2
✓ Branch 0 taken 448 times.
✓ Branch 1 taken 28 times.
476 for(int32_t x = 0; x < 16; ++x)
617 {
618
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 448 times.
7616 for(int32_t y = 0; y < 16; ++y)
619 {
620 7168 int32_t color = getpixel(tmpbmp, x, y);
621
5/5
✓ Branch 0 taken 6594 times.
✓ Branch 1 taken 133 times.
✓ Branch 2 taken 154 times.
✓ Branch 3 taken 161 times.
✓ Branch 4 taken 126 times.
7168 switch(color)
622 {
623 case dvc(1):
624 133 color = jwin_pal[jcCURSORMISC];
625 133 break;
626 case dvc(2):
627 154 color = jwin_pal[jcCURSOROUTLINE];
628 154 break;
629 case dvc(3):
630 161 color = jwin_pal[jcCURSORLIGHT];
631 161 break;
632 case dvc(5):
633 126 color = jwin_pal[jcCURSORDARK];
634 126 break;
635 }
636 7168 putpixel(subbmp, x, y, color);
637 7168 }
638 448 }
639
1/2
✓ Branch 0 taken 28 times.
✗ Branch 1 not taken.
28 if(sz!=16)
640 28 stretch_blit(subbmp, zcmouse[j], 0, 0, 16, 16, 0, 0, sz, sz);
641 else
642 blit(subbmp, zcmouse[j], 0, 0, 0, 0, 16, 16);
643 28 destroy_bitmap(tmpbmp);
644 28 destroy_bitmap(subbmp);
645 28 }
646 7 set_mouse_sprite(zcmouse[0]);
647
648 // Must attempt to show cursor for allegro 5 to render it with the associated palette.
649 7 set_palette(*hw_palette);
650 7 show_mouse(screen);
651 7 show_mouse(NULL);
652
653 7 unscare_mouse();
654 7 game_pal();
655 7 }
656
657 // sets the video mode and initializes the palette and mouse sprite
658 7 bool game_vid_mode(int32_t mode,int32_t wait)
659 {
660
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(set_gfx_mode(mode,resx,resy,0,0)!=0)
661 {
662 return false;
663 }
664
665 7 scrx = (resx-320)>>1;
666 7 scry = (resy-240)>>1;
667
2/2
✓ Branch 0 taken 28 times.
✓ Branch 1 taken 7 times.
35 for(int32_t q = 0; q < 4; ++q)
668 28 zcmouse[q] = NULL;
669 7 load_mouse();
670 7 set_mouse_sprite(zcmouse[0]);
671
672
2/2
✓ Branch 0 taken 112 times.
✓ Branch 1 taken 7 times.
119 for(int32_t i=240; i<256; i++)
673 112 RAMpal[i]=((RGB*)datafile[PAL_GUI].dat)[i];
674
675 7 set_palette(RAMpal);
676 7 clear_to_color(screen,BLACK);
677
678 7 rest(wait);
679 7 return true;
680 7 }
681
682 void null_quest()
683 {
684 char qstdat_string[2048];
685 strcpy(qstdat_string,moduledata.datafiles[qst_dat]);
686 strcat(qstdat_string,"#NESQST_NEW_QST");
687
688 #ifdef __EMSCRIPTEN__
689 // The quest template data file is not included because it's really big and isn't really needed
690 // for the player, except to initialize some graphics. Those same graphics exist in this quest file,
691 // which is much smaller.
692 strcpy(qstdat_string, "modules/classic/title_gfx.dat");
693 #endif
694
695 byte skip_flags[4] = { 0 };
696
697 loadquest(qstdat_string,&QHeader,&QMisc,tunes+ZC_MIDI_COUNT,false,true,true,true,skip_flags,0,false);
698 }
699
700 void init_NES_mode()
701 {
702 /*
703 // qst.dat may not load correctly without this...
704 QHeader.templatepath[0]='\0';
705
706 if(!init_colordata(true, &QHeader, &QMisc))
707 {
708 return;
709 }
710
711 loadfullpal();
712 init_tiles(false, &QHeader);
713 */
714 null_quest();
715 }
716
717 //----------------------------------------------------------------
718
719 qword trianglelines[16]=
720 {
721 0x0000000000000000ULL,
722 0xFD00000000000000ULL,
723 0xFDFD000000000000ULL,
724 0xFDFDFD0000000000ULL,
725 0xFDFDFDFD00000000ULL,
726 0xFDFDFDFDFD000000ULL,
727 0xFDFDFDFDFDFD0000ULL,
728 0xFDFDFDFDFDFDFD00ULL,
729 0xFDFDFDFDFDFDFDFDULL,
730 0x00FDFDFDFDFDFDFDULL,
731 0x0000FDFDFDFDFDFDULL,
732 0x000000FDFDFDFDFDULL,
733 0x00000000FDFDFDFDULL,
734 0x0000000000FDFDFDULL,
735 0x000000000000FDFDULL,
736 0x00000000000000FDULL,
737 };
738
739 word screen_triangles[28][32];
740 /*
741 qword triangles[4][16]= //[direction][value]
742 {
743 {
744 0x00000000, 0x10000000, 0x21000000, 0x32100000, 0x43210000, 0x54321000, 0x65432100, 0x76543210, 0x87654321, 0x88765432, 0x88876543, 0x88887654, 0x88888765, 0x88888876, 0x88888887, 0x88888888
745 },
746 {
747 0x00000000, 0xF0000000, 0xEF000000, 0xFDF00000, 0xCFDF0000, 0xBCFDF000, 0xABCFDF00, 0x9ABCFDF0, 0x89ABCFDF, 0x889ABCFD, 0x8889ABCD, 0x88889ABC, 0x888889AB, 0x8888889A, 0x88888889, 0x88888888
748 },
749 {
750 0x00000000, 0x00000001, 0x00000012, 0x00000123, 0x00001234, 0x00012345, 0x00123456, 0x01234567, 0x12345678, 0x23456788, 0x34567888, 0x45678888, 0x56788888, 0x67888888, 0x78888888, 0x88888888
751 },
752 {
753 0x00000000, 0x0000000F, 0x000000FE, 0x00000FED, 0x0000FEDC, 0x000FEDCB, 0x00FEDCBA, 0x0FEDCBA9, 0xFEDCBA98, 0xEDCBA988, 0xDCBA9888, 0xCBA98888, 0xBA988888, 0xA9888888, 0x98888888, 0x88888888
754 }
755 };
756 */
757
758
759 /*
760 byte triangles[4][16][8]= //[direction][value][line]
761 {
762 {
763 {
764 0, 0, 0, 0, 0, 0, 0, 0
765 },
766 {
767 1, 0, 0, 0, 0, 0, 0, 0
768 },
769 {
770 2, 1, 0, 0, 0, 0, 0, 0
771 },
772 {
773 3, 2, 1, 0, 0, 0, 0, 0
774 },
775 {
776 4, 3, 2, 1, 0, 0, 0, 0
777 },
778 {
779 5, 4, 3, 2, 1, 0, 0, 0
780 },
781 {
782 6, 5, 4, 3, 2, 1, 0, 0
783 },
784 {
785 7, 6, 5, 4, 3, 2, 1, 0
786 },
787 {
788 8, 7, 6, 5, 4, 3, 2, 1
789 },
790 {
791 8, 8, 7, 6, 5, 4, 3, 2
792 },
793 {
794 8, 8, 8, 7, 6, 5, 4, 3
795 },
796 {
797 8, 8, 8, 8, 7, 6, 5, 4
798 },
799 {
800 8, 8, 8, 8, 8, 7, 6, 5
801 },
802 {
803 8, 8, 8, 8, 8, 8, 7, 6
804 },
805 {
806 8, 8, 8, 8, 8, 8, 8, 7
807 },
808 {
809 8, 8, 8, 8, 8, 8, 8, 8
810 }
811 },
812 {
813 {
814 0, 0, 0, 0, 0, 0, 0, 0
815 },
816 {
817 15, 0, 0, 0, 0, 0, 0, 0
818 },
819 {
820 14, 15, 0, 0, 0, 0, 0, 0
821 },
822 {
823 13, 14, 15, 0, 0, 0, 0, 0
824 },
825 {
826 12, 13, 14, 15, 0, 0, 0, 0
827 },
828 {
829 11, 12, 13, 14, 15, 0, 0, 0
830 },
831 {
832 10, 11, 12, 13, 14, 15, 0, 0
833 },
834 {
835 9, 10, 11, 12, 13, 14, 15, 0
836 },
837 {
838 8, 9, 10, 11, 12, 13, 14, 15
839 },
840 {
841 8, 8, 9, 10, 11, 12, 13, 14
842 },
843 {
844 8, 8, 8, 9, 10, 11, 12, 13
845 },
846 {
847 8, 8, 8, 8, 9, 10, 11, 12
848 },
849 {
850 8, 8, 8, 8, 8, 9, 10, 11
851 },
852 {
853 8, 8, 8, 8, 8, 8, 9, 10
854 },
855 {
856 8, 8, 8, 8, 8, 8, 8, 9
857 },
858 {
859 8, 8, 8, 8, 8, 8, 8, 8
860 }
861 },
862 {
863 {
864 0, 0, 0, 0, 0, 0, 0, 0
865 },
866 {
867 0, 0, 0, 0, 0, 0, 0, 1
868 },
869 {
870 0, 0, 0, 0, 0, 0, 1, 2
871 },
872 {
873 0, 0, 0, 0, 0, 1, 2, 3
874 },
875 {
876 0, 0, 0, 0, 1, 2, 3, 4
877 },
878 {
879 0, 0, 0, 1, 2, 3, 4, 5
880 },
881 {
882 0, 0, 1, 2, 3, 4, 5, 6
883 },
884 {
885 0, 1, 2, 3, 4, 5, 6, 7
886 },
887 {
888 1, 2, 3, 4, 5, 6, 7, 8
889 },
890 {
891 2, 3, 4, 5, 6, 7, 8, 8
892 },
893 {
894 3, 4, 5, 6, 7, 8, 8, 8
895 },
896 {
897 4, 5, 6, 7, 8, 8, 8, 8
898 },
899 {
900 5, 6, 7, 8, 8, 8, 8, 8
901 },
902 {
903 6, 7, 8, 8, 8, 8, 8, 8
904 },
905 {
906 7, 8, 8, 8, 8, 8, 8, 8
907 },
908 {
909 8, 8, 8, 8, 8, 8, 8, 8
910 }
911 },
912 {
913 {
914 0, 0, 0, 0, 0, 0, 0, 0
915 },
916 {
917 0, 0, 0, 0, 0, 0, 0, 15
918 },
919 {
920 0, 0, 0, 0, 0, 0, 15, 14
921 },
922 {
923 0, 0, 0, 0, 0, 15, 14, 13
924 },
925 {
926 0, 0, 0, 0, 15, 14, 13, 12
927 },
928 {
929 0, 0, 0, 15, 14, 13, 12, 11
930 },
931 {
932 0, 0, 15, 14, 13, 12, 11, 10
933 },
934 {
935 0, 15, 14, 13, 12, 11, 10, 9
936 },
937 {
938 15, 14, 13, 12, 11, 10, 9, 8
939 },
940 {
941 14, 13, 12, 11, 10, 9, 8, 8
942 },
943 {
944 13, 12, 11, 10, 9, 8, 8, 8
945 },
946 {
947 12, 11, 10, 9, 8, 8, 8, 8
948 },
949 {
950 11, 10, 9, 8, 8, 8, 8, 8
951 },
952 {
953 10, 9, 8, 8, 8, 8, 8, 8
954 },
955 {
956 9, 8, 8, 8, 8, 8, 8, 8
957 },
958 {
959 8, 8, 8, 8, 8, 8, 8, 8
960 }
961 }
962 };
963 */
964
965
966
967 /*
968 for (int32_t blockrow=0; blockrow<30; ++i)
969 {
970 for (int32_t linerow=0; linerow<8; ++i)
971 {
972 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
973 for (int32_t blockcolumn=0; blockcolumn<40; ++i)
974 {
975 triangleline=triangles[0][screen_triangles[blockrow][blockcolumn]][linerow];
976 ++triangleline;
977 }
978 }
979 }
980 */
981
982 // the ULL suffixes are to prevent this warning:
983 // warning: integer constant is too large for "int32_t" type
984
985 qword triangles[4][16][8]= //[direction][value][line]
986 {
987 {
988 {
989 0x0000000000000000ULL,
990 0x0000000000000000ULL,
991 0x0000000000000000ULL,
992 0x0000000000000000ULL,
993 0x0000000000000000ULL,
994 0x0000000000000000ULL,
995 0x0000000000000000ULL,
996 0x0000000000000000ULL
997 },
998 {
999 0xFD00000000000000ULL,
1000 0x0000000000000000ULL,
1001 0x0000000000000000ULL,
1002 0x0000000000000000ULL,
1003 0x0000000000000000ULL,
1004 0x0000000000000000ULL,
1005 0x0000000000000000ULL,
1006 0x0000000000000000ULL
1007 },
1008 {
1009 0xFDFD000000000000ULL,
1010 0xFD00000000000000ULL,
1011 0x0000000000000000ULL,
1012 0x0000000000000000ULL,
1013 0x0000000000000000ULL,
1014 0x0000000000000000ULL,
1015 0x0000000000000000ULL,
1016 0x0000000000000000ULL
1017 },
1018 {
1019 0xFDFDFD0000000000ULL,
1020 0xFDFD000000000000ULL,
1021 0xFD00000000000000ULL,
1022 0x0000000000000000ULL,
1023 0x0000000000000000ULL,
1024 0x0000000000000000ULL,
1025 0x0000000000000000ULL,
1026 0x0000000000000000ULL
1027 },
1028 {
1029 0xFDFDFDFD00000000ULL,
1030 0xFDFDFD0000000000ULL,
1031 0xFDFD000000000000ULL,
1032 0xFD00000000000000ULL,
1033 0x0000000000000000ULL,
1034 0x0000000000000000ULL,
1035 0x0000000000000000ULL,
1036 0x0000000000000000ULL
1037 },
1038 {
1039 0xFDFDFDFDFD000000ULL,
1040 0xFDFDFDFD00000000ULL,
1041 0xFDFDFD0000000000ULL,
1042 0xFDFD000000000000ULL,
1043 0xFD00000000000000ULL,
1044 0x0000000000000000ULL,
1045 0x0000000000000000ULL,
1046 0x0000000000000000ULL
1047 },
1048 {
1049 0xFDFDFDFDFDFD0000ULL,
1050 0xFDFDFDFDFD000000ULL,
1051 0xFDFDFDFD00000000ULL,
1052 0xFDFDFD0000000000ULL,
1053 0xFDFD000000000000ULL,
1054 0xFD00000000000000ULL,
1055 0x0000000000000000ULL,
1056 0x0000000000000000ULL
1057 },
1058 {
1059 0xFDFDFDFDFDFDFD00ULL,
1060 0xFDFDFDFDFDFD0000ULL,
1061 0xFDFDFDFDFD000000ULL,
1062 0xFDFDFDFD00000000ULL,
1063 0xFDFDFD0000000000ULL,
1064 0xFDFD000000000000ULL,
1065 0xFD00000000000000ULL,
1066 0x0000000000000000ULL
1067 },
1068 {
1069 0xFDFDFDFDFDFDFDFDULL,
1070 0xFDFDFDFDFDFDFD00ULL,
1071 0xFDFDFDFDFDFD0000ULL,
1072 0xFDFDFDFDFD000000ULL,
1073 0xFDFDFDFD00000000ULL,
1074 0xFDFDFD0000000000ULL,
1075 0xFDFD000000000000ULL,
1076 0xFD00000000000000ULL
1077 },
1078 {
1079 0xFDFDFDFDFDFDFDFDULL,
1080 0xFDFDFDFDFDFDFDFDULL,
1081 0xFDFDFDFDFDFDFD00ULL,
1082 0xFDFDFDFDFDFD0000ULL,
1083 0xFDFDFDFDFD000000ULL,
1084 0xFDFDFDFD00000000ULL,
1085 0xFDFDFD0000000000ULL,
1086 0xFDFD000000000000ULL
1087 },
1088 {
1089 0xFDFDFDFDFDFDFDFDULL,
1090 0xFDFDFDFDFDFDFDFDULL,
1091 0xFDFDFDFDFDFDFDFDULL,
1092 0xFDFDFDFDFDFDFD00ULL,
1093 0xFDFDFDFDFDFD0000ULL,
1094 0xFDFDFDFDFD000000ULL,
1095 0xFDFDFDFD00000000ULL,
1096 0xFDFDFD0000000000ULL
1097 },
1098 {
1099 0xFDFDFDFDFDFDFDFDULL,
1100 0xFDFDFDFDFDFDFDFDULL,
1101 0xFDFDFDFDFDFDFDFDULL,
1102 0xFDFDFDFDFDFDFDFDULL,
1103 0xFDFDFDFDFDFDFD00ULL,
1104 0xFDFDFDFDFDFD0000ULL,
1105 0xFDFDFDFDFD000000ULL,
1106 0xFDFDFDFD00000000ULL
1107 },
1108 {
1109 0xFDFDFDFDFDFDFDFDULL,
1110 0xFDFDFDFDFDFDFDFDULL,
1111 0xFDFDFDFDFDFDFDFDULL,
1112 0xFDFDFDFDFDFDFDFDULL,
1113 0xFDFDFDFDFDFDFDFDULL,
1114 0xFDFDFDFDFDFDFD00ULL,
1115 0xFDFDFDFDFDFD0000ULL,
1116 0xFDFDFDFDFD000000ULL
1117 },
1118 {
1119 0xFDFDFDFDFDFDFDFDULL,
1120 0xFDFDFDFDFDFDFDFDULL,
1121 0xFDFDFDFDFDFDFDFDULL,
1122 0xFDFDFDFDFDFDFDFDULL,
1123 0xFDFDFDFDFDFDFDFDULL,
1124 0xFDFDFDFDFDFDFDFDULL,
1125 0xFDFDFDFDFDFDFD00ULL,
1126 0xFDFDFDFDFDFD0000ULL
1127 },
1128 {
1129 0xFDFDFDFDFDFDFDFDULL,
1130 0xFDFDFDFDFDFDFDFDULL,
1131 0xFDFDFDFDFDFDFDFDULL,
1132 0xFDFDFDFDFDFDFDFDULL,
1133 0xFDFDFDFDFDFDFDFDULL,
1134 0xFDFDFDFDFDFDFDFDULL,
1135 0xFDFDFDFDFDFDFDFDULL,
1136 0xFDFDFDFDFDFDFD00ULL
1137 },
1138 {
1139 0xFDFDFDFDFDFDFDFDULL,
1140 0xFDFDFDFDFDFDFDFDULL,
1141 0xFDFDFDFDFDFDFDFDULL,
1142 0xFDFDFDFDFDFDFDFDULL,
1143 0xFDFDFDFDFDFDFDFDULL,
1144 0xFDFDFDFDFDFDFDFDULL,
1145 0xFDFDFDFDFDFDFDFDULL,
1146 0xFDFDFDFDFDFDFDFDULL
1147 }
1148 },
1149 {
1150 {
1151 0x0000000000000000ULL,
1152 0x0000000000000000ULL,
1153 0x0000000000000000ULL,
1154 0x0000000000000000ULL,
1155 0x0000000000000000ULL,
1156 0x0000000000000000ULL,
1157 0x0000000000000000ULL,
1158 0x0000000000000000ULL
1159 },
1160 {
1161 0x00000000000000FDULL,
1162 0x0000000000000000ULL,
1163 0x0000000000000000ULL,
1164 0x0000000000000000ULL,
1165 0x0000000000000000ULL,
1166 0x0000000000000000ULL,
1167 0x0000000000000000ULL,
1168 0x0000000000000000ULL
1169 },
1170 {
1171 0x000000000000FDFDULL,
1172 0x00000000000000FDULL,
1173 0x0000000000000000ULL,
1174 0x0000000000000000ULL,
1175 0x0000000000000000ULL,
1176 0x0000000000000000ULL,
1177 0x0000000000000000ULL,
1178 0x0000000000000000ULL
1179 },
1180 {
1181 0x0000000000FDFDFDULL,
1182 0x000000000000FDFDULL,
1183 0x00000000000000FDULL,
1184 0x0000000000000000ULL,
1185 0x0000000000000000ULL,
1186 0x0000000000000000ULL,
1187 0x0000000000000000ULL,
1188 0x0000000000000000ULL
1189 },
1190 {
1191 0x00000000FDFDFDFDULL,
1192 0x0000000000FDFDFDULL,
1193 0x000000000000FDFDULL,
1194 0x00000000000000FDULL,
1195 0x0000000000000000ULL,
1196 0x0000000000000000ULL,
1197 0x0000000000000000ULL,
1198 0x0000000000000000ULL
1199 },
1200 {
1201 0x000000FDFDFDFDFDULL,
1202 0x00000000FDFDFDFDULL,
1203 0x0000000000FDFDFDULL,
1204 0x000000000000FDFDULL,
1205 0x00000000000000FDULL,
1206 0x0000000000000000ULL,
1207 0x0000000000000000ULL,
1208 0x0000000000000000ULL
1209 },
1210 {
1211 0x0000FDFDFDFDFDFDULL,
1212 0x000000FDFDFDFDFDULL,
1213 0x00000000FDFDFDFDULL,
1214 0x0000000000FDFDFDULL,
1215 0x000000000000FDFDULL,
1216 0x00000000000000FDULL,
1217 0x0000000000000000ULL,
1218 0x0000000000000000ULL
1219 },
1220 {
1221 0x00FDFDFDFDFDFDFDULL,
1222 0x0000FDFDFDFDFDFDULL,
1223 0x000000FDFDFDFDFDULL,
1224 0x00000000FDFDFDFDULL,
1225 0x0000000000FDFDFDULL,
1226 0x000000000000FDFDULL,
1227 0x00000000000000FDULL,
1228 0x0000000000000000ULL
1229 },
1230 {
1231 0xFDFDFDFDFDFDFDFDULL,
1232 0x00FDFDFDFDFDFDFDULL,
1233 0x0000FDFDFDFDFDFDULL,
1234 0x000000FDFDFDFDFDULL,
1235 0x00000000FDFDFDFDULL,
1236 0x0000000000FDFDFDULL,
1237 0x000000000000FDFDULL,
1238 0x00000000000000FDULL
1239 },
1240 {
1241 0xFDFDFDFDFDFDFDFDULL,
1242 0xFDFDFDFDFDFDFDFDULL,
1243 0x00FDFDFDFDFDFDFDULL,
1244 0x0000FDFDFDFDFDFDULL,
1245 0x000000FDFDFDFDFDULL,
1246 0x00000000FDFDFDFDULL,
1247 0x0000000000FDFDFDULL,
1248 0x000000000000FDFDULL
1249 },
1250 {
1251 0xFDFDFDFDFDFDFDFDULL,
1252 0xFDFDFDFDFDFDFDFDULL,
1253 0xFDFDFDFDFDFDFDFDULL,
1254 0x00FDFDFDFDFDFDFDULL,
1255 0x0000FDFDFDFDFDFDULL,
1256 0x000000FDFDFDFDFDULL,
1257 0x00000000FDFDFDFDULL,
1258 0x0000000000FDFDFDULL
1259 },
1260 {
1261 0xFDFDFDFDFDFDFDFDULL,
1262 0xFDFDFDFDFDFDFDFDULL,
1263 0xFDFDFDFDFDFDFDFDULL,
1264 0xFDFDFDFDFDFDFDFDULL,
1265 0x00FDFDFDFDFDFDFDULL,
1266 0x0000FDFDFDFDFDFDULL,
1267 0x000000FDFDFDFDFDULL,
1268 0x00000000FDFDFDFDULL
1269 },
1270 {
1271 0xFDFDFDFDFDFDFDFDULL,
1272 0xFDFDFDFDFDFDFDFDULL,
1273 0xFDFDFDFDFDFDFDFDULL,
1274 0xFDFDFDFDFDFDFDFDULL,
1275 0xFDFDFDFDFDFDFDFDULL,
1276 0x00FDFDFDFDFDFDFDULL,
1277 0x0000FDFDFDFDFDFDULL,
1278 0x000000FDFDFDFDFDULL
1279 },
1280 {
1281 0xFDFDFDFDFDFDFDFDULL,
1282 0xFDFDFDFDFDFDFDFDULL,
1283 0xFDFDFDFDFDFDFDFDULL,
1284 0xFDFDFDFDFDFDFDFDULL,
1285 0xFDFDFDFDFDFDFDFDULL,
1286 0xFDFDFDFDFDFDFDFDULL,
1287 0x00FDFDFDFDFDFDFDULL,
1288 0x0000FDFDFDFDFDFDULL
1289 },
1290 {
1291 0xFDFDFDFDFDFDFDFDULL,
1292 0xFDFDFDFDFDFDFDFDULL,
1293 0xFDFDFDFDFDFDFDFDULL,
1294 0xFDFDFDFDFDFDFDFDULL,
1295 0xFDFDFDFDFDFDFDFDULL,
1296 0xFDFDFDFDFDFDFDFDULL,
1297 0xFDFDFDFDFDFDFDFDULL,
1298 0x00FDFDFDFDFDFDFDULL
1299 },
1300 {
1301 0xFDFDFDFDFDFDFDFDULL,
1302 0xFDFDFDFDFDFDFDFDULL,
1303 0xFDFDFDFDFDFDFDFDULL,
1304 0xFDFDFDFDFDFDFDFDULL,
1305 0xFDFDFDFDFDFDFDFDULL,
1306 0xFDFDFDFDFDFDFDFDULL,
1307 0xFDFDFDFDFDFDFDFDULL,
1308 0xFDFDFDFDFDFDFDFDULL
1309 }
1310 },
1311 {
1312 {
1313 0x0000000000000000ULL,
1314 0x0000000000000000ULL,
1315 0x0000000000000000ULL,
1316 0x0000000000000000ULL,
1317 0x0000000000000000ULL,
1318 0x0000000000000000ULL,
1319 0x0000000000000000ULL,
1320 0x0000000000000000ULL
1321 },
1322 {
1323 0x0000000000000000ULL,
1324 0x0000000000000000ULL,
1325 0x0000000000000000ULL,
1326 0x0000000000000000ULL,
1327 0x0000000000000000ULL,
1328 0x0000000000000000ULL,
1329 0x0000000000000000ULL,
1330 0xFD00000000000000ULL
1331 },
1332 {
1333 0x0000000000000000ULL,
1334 0x0000000000000000ULL,
1335 0x0000000000000000ULL,
1336 0x0000000000000000ULL,
1337 0x0000000000000000ULL,
1338 0x0000000000000000ULL,
1339 0xFD00000000000000ULL,
1340 0xFDFD000000000000ULL
1341 },
1342 {
1343 0x0000000000000000ULL,
1344 0x0000000000000000ULL,
1345 0x0000000000000000ULL,
1346 0x0000000000000000ULL,
1347 0x0000000000000000ULL,
1348 0xFD00000000000000ULL,
1349 0xFDFD000000000000ULL,
1350 0xFDFDFD0000000000ULL
1351 },
1352 {
1353 0x0000000000000000ULL,
1354 0x0000000000000000ULL,
1355 0x0000000000000000ULL,
1356 0x0000000000000000ULL,
1357 0xFD00000000000000ULL,
1358 0xFDFD000000000000ULL,
1359 0xFDFDFD0000000000ULL,
1360 0xFDFDFDFD00000000ULL
1361 },
1362 {
1363 0x0000000000000000ULL,
1364 0x0000000000000000ULL,
1365 0x0000000000000000ULL,
1366 0xFD00000000000000ULL,
1367 0xFDFD000000000000ULL,
1368 0xFDFDFD0000000000ULL,
1369 0xFDFDFDFD00000000ULL,
1370 0xFDFDFDFDFD000000ULL
1371 },
1372 {
1373 0x0000000000000000ULL,
1374 0x0000000000000000ULL,
1375 0xFD00000000000000ULL,
1376 0xFDFD000000000000ULL,
1377 0xFDFDFD0000000000ULL,
1378 0xFDFDFDFD00000000ULL,
1379 0xFDFDFDFDFD000000ULL,
1380 0xFDFDFDFDFDFD0000ULL
1381 },
1382 {
1383 0x0000000000000000ULL,
1384 0xFD00000000000000ULL,
1385 0xFDFD000000000000ULL,
1386 0xFDFDFD0000000000ULL,
1387 0xFDFDFDFD00000000ULL,
1388 0xFDFDFDFDFD000000ULL,
1389 0xFDFDFDFDFDFD0000ULL,
1390 0xFDFDFDFDFDFDFD00ULL
1391 },
1392 {
1393 0xFD00000000000000ULL,
1394 0xFDFD000000000000ULL,
1395 0xFDFDFD0000000000ULL,
1396 0xFDFDFDFD00000000ULL,
1397 0xFDFDFDFDFD000000ULL,
1398 0xFDFDFDFDFDFD0000ULL,
1399 0xFDFDFDFDFDFDFD00ULL,
1400 0xFDFDFDFDFDFDFDFDULL
1401 },
1402 {
1403 0xFDFD000000000000ULL,
1404 0xFDFDFD0000000000ULL,
1405 0xFDFDFDFD00000000ULL,
1406 0xFDFDFDFDFD000000ULL,
1407 0xFDFDFDFDFDFD0000ULL,
1408 0xFDFDFDFDFDFDFD00ULL,
1409 0xFDFDFDFDFDFDFDFDULL,
1410 0xFDFDFDFDFDFDFDFDULL
1411 },
1412 {
1413 0xFDFDFD0000000000ULL,
1414 0xFDFDFDFD00000000ULL,
1415 0xFDFDFDFDFD000000ULL,
1416 0xFDFDFDFDFDFD0000ULL,
1417 0xFDFDFDFDFDFDFD00ULL,
1418 0xFDFDFDFDFDFDFDFDULL,
1419 0xFDFDFDFDFDFDFDFDULL,
1420 0xFDFDFDFDFDFDFDFDULL
1421 },
1422 {
1423 0xFDFDFDFD00000000ULL,
1424 0xFDFDFDFDFD000000ULL,
1425 0xFDFDFDFDFDFD0000ULL,
1426 0xFDFDFDFDFDFDFD00ULL,
1427 0xFDFDFDFDFDFDFDFDULL,
1428 0xFDFDFDFDFDFDFDFDULL,
1429 0xFDFDFDFDFDFDFDFDULL,
1430 0xFDFDFDFDFDFDFDFDULL
1431 },
1432 {
1433 0xFDFDFDFDFD000000ULL,
1434 0xFDFDFDFDFDFD0000ULL,
1435 0xFDFDFDFDFDFDFD00ULL,
1436 0xFDFDFDFDFDFDFDFDULL,
1437 0xFDFDFDFDFDFDFDFDULL,
1438 0xFDFDFDFDFDFDFDFDULL,
1439 0xFDFDFDFDFDFDFDFDULL,
1440 0xFDFDFDFDFDFDFDFDULL
1441 },
1442 {
1443 0xFDFDFDFDFDFD0000ULL,
1444 0xFDFDFDFDFDFDFD00ULL,
1445 0xFDFDFDFDFDFDFDFDULL,
1446 0xFDFDFDFDFDFDFDFDULL,
1447 0xFDFDFDFDFDFDFDFDULL,
1448 0xFDFDFDFDFDFDFDFDULL,
1449 0xFDFDFDFDFDFDFDFDULL,
1450 0xFDFDFDFDFDFDFDFDULL
1451 },
1452 {
1453 0xFDFDFDFDFDFDFD00ULL,
1454 0xFDFDFDFDFDFDFDFDULL,
1455 0xFDFDFDFDFDFDFDFDULL,
1456 0xFDFDFDFDFDFDFDFDULL,
1457 0xFDFDFDFDFDFDFDFDULL,
1458 0xFDFDFDFDFDFDFDFDULL,
1459 0xFDFDFDFDFDFDFDFDULL,
1460 0xFDFDFDFDFDFDFDFDULL
1461 },
1462 {
1463 0xFDFDFDFDFDFDFDFDULL,
1464 0xFDFDFDFDFDFDFDFDULL,
1465 0xFDFDFDFDFDFDFDFDULL,
1466 0xFDFDFDFDFDFDFDFDULL,
1467 0xFDFDFDFDFDFDFDFDULL,
1468 0xFDFDFDFDFDFDFDFDULL,
1469 0xFDFDFDFDFDFDFDFDULL,
1470 0xFDFDFDFDFDFDFDFDULL
1471 }
1472 },
1473 {
1474 {
1475 0x0000000000000000ULL,
1476 0x0000000000000000ULL,
1477 0x0000000000000000ULL,
1478 0x0000000000000000ULL,
1479 0x0000000000000000ULL,
1480 0x0000000000000000ULL,
1481 0x0000000000000000ULL,
1482 0x0000000000000000ULL
1483 },
1484 {
1485 0x0000000000000000ULL,
1486 0x0000000000000000ULL,
1487 0x0000000000000000ULL,
1488 0x0000000000000000ULL,
1489 0x0000000000000000ULL,
1490 0x0000000000000000ULL,
1491 0x0000000000000000ULL,
1492 0x00000000000000FDULL
1493 },
1494 {
1495 0x0000000000000000ULL,
1496 0x0000000000000000ULL,
1497 0x0000000000000000ULL,
1498 0x0000000000000000ULL,
1499 0x0000000000000000ULL,
1500 0x0000000000000000ULL,
1501 0x00000000000000FDULL,
1502 0x000000000000FDFDULL
1503 },
1504 {
1505 0x0000000000000000ULL,
1506 0x0000000000000000ULL,
1507 0x0000000000000000ULL,
1508 0x0000000000000000ULL,
1509 0x0000000000000000ULL,
1510 0x00000000000000FDULL,
1511 0x000000000000FDFDULL,
1512 0x0000000000FDFDFDULL
1513 },
1514 {
1515 0x0000000000000000ULL,
1516 0x0000000000000000ULL,
1517 0x0000000000000000ULL,
1518 0x0000000000000000ULL,
1519 0x00000000000000FDULL,
1520 0x000000000000FDFDULL,
1521 0x0000000000FDFDFDULL,
1522 0x00000000FDFDFDFDULL
1523 },
1524 {
1525 0x0000000000000000ULL,
1526 0x0000000000000000ULL,
1527 0x0000000000000000ULL,
1528 0x00000000000000FDULL,
1529 0x000000000000FDFDULL,
1530 0x0000000000FDFDFDULL,
1531 0x00000000FDFDFDFDULL,
1532 0x000000FDFDFDFDFDULL
1533 },
1534 {
1535 0x0000000000000000ULL,
1536 0x0000000000000000ULL,
1537 0x00000000000000FDULL,
1538 0x000000000000FDFDULL,
1539 0x0000000000FDFDFDULL,
1540 0x00000000FDFDFDFDULL,
1541 0x000000FDFDFDFDFDULL,
1542 0x0000FDFDFDFDFDFDULL
1543 },
1544 {
1545 0x0000000000000000ULL,
1546 0x00000000000000FDULL,
1547 0x000000000000FDFDULL,
1548 0x0000000000FDFDFDULL,
1549 0x00000000FDFDFDFDULL,
1550 0x000000FDFDFDFDFDULL,
1551 0x0000FDFDFDFDFDFDULL,
1552 0x00FDFDFDFDFDFDFDULL
1553 },
1554 {
1555 0x00000000000000FDULL,
1556 0x000000000000FDFDULL,
1557 0x0000000000FDFDFDULL,
1558 0x00000000FDFDFDFDULL,
1559 0x000000FDFDFDFDFDULL,
1560 0x0000FDFDFDFDFDFDULL,
1561 0x00FDFDFDFDFDFDFDULL,
1562 0xFDFDFDFDFDFDFDFDULL
1563 },
1564 {
1565 0x000000000000FDFDULL,
1566 0x0000000000FDFDFDULL,
1567 0x00000000FDFDFDFDULL,
1568 0x000000FDFDFDFDFDULL,
1569 0x0000FDFDFDFDFDFDULL,
1570 0x00FDFDFDFDFDFDFDULL,
1571 0xFDFDFDFDFDFDFDFDULL,
1572 0xFDFDFDFDFDFDFDFDULL
1573 },
1574 {
1575 0x0000000000FDFDFDULL,
1576 0x00000000FDFDFDFDULL,
1577 0x000000FDFDFDFDFDULL,
1578 0x0000FDFDFDFDFDFDULL,
1579 0x00FDFDFDFDFDFDFDULL,
1580 0xFDFDFDFDFDFDFDFDULL,
1581 0xFDFDFDFDFDFDFDFDULL,
1582 0xFDFDFDFDFDFDFDFDULL
1583 },
1584 {
1585 0x00000000FDFDFDFDULL,
1586 0x000000FDFDFDFDFDULL,
1587 0x0000FDFDFDFDFDFDULL,
1588 0x00FDFDFDFDFDFDFDULL,
1589 0xFDFDFDFDFDFDFDFDULL,
1590 0xFDFDFDFDFDFDFDFDULL,
1591 0xFDFDFDFDFDFDFDFDULL,
1592 0xFDFDFDFDFDFDFDFDULL
1593 },
1594 {
1595 0x000000FDFDFDFDFDULL,
1596 0x0000FDFDFDFDFDFDULL,
1597 0x00FDFDFDFDFDFDFDULL,
1598 0xFDFDFDFDFDFDFDFDULL,
1599 0xFDFDFDFDFDFDFDFDULL,
1600 0xFDFDFDFDFDFDFDFDULL,
1601 0xFDFDFDFDFDFDFDFDULL,
1602 0xFDFDFDFDFDFDFDFDULL
1603 },
1604 {
1605 0x0000FDFDFDFDFDFDULL,
1606 0x00FDFDFDFDFDFDFDULL,
1607 0xFDFDFDFDFDFDFDFDULL,
1608 0xFDFDFDFDFDFDFDFDULL,
1609 0xFDFDFDFDFDFDFDFDULL,
1610 0xFDFDFDFDFDFDFDFDULL,
1611 0xFDFDFDFDFDFDFDFDULL,
1612 0xFDFDFDFDFDFDFDFDULL
1613 },
1614 {
1615 0x00FDFDFDFDFDFDFDULL,
1616 0xFDFDFDFDFDFDFDFDULL,
1617 0xFDFDFDFDFDFDFDFDULL,
1618 0xFDFDFDFDFDFDFDFDULL,
1619 0xFDFDFDFDFDFDFDFDULL,
1620 0xFDFDFDFDFDFDFDFDULL,
1621 0xFDFDFDFDFDFDFDFDULL,
1622 0xFDFDFDFDFDFDFDFDULL
1623 },
1624 {
1625 0xFDFDFDFDFDFDFDFDULL,
1626 0xFDFDFDFDFDFDFDFDULL,
1627 0xFDFDFDFDFDFDFDFDULL,
1628 0xFDFDFDFDFDFDFDFDULL,
1629 0xFDFDFDFDFDFDFDFDULL,
1630 0xFDFDFDFDFDFDFDFDULL,
1631 0xFDFDFDFDFDFDFDFDULL,
1632 0xFDFDFDFDFDFDFDFDULL
1633 }
1634 }
1635 };
1636
1637 int32_t black_opening_count=0;
1638 int32_t black_opening_x,black_opening_y;
1639 int32_t black_opening_shape;
1640
1641 38 int32_t choose_opening_shape()
1642 {
1643 // First, count how many bits are set
1644 38 int32_t numBits=0;
1645 int32_t bitCounter;
1646
1647
2/2
✓ Branch 0 taken 190 times.
✓ Branch 1 taken 38 times.
228 for(int32_t i=0; i<bosMAX; i++)
1648 {
1649
2/2
✓ Branch 0 taken 152 times.
✓ Branch 1 taken 38 times.
190 if(COOLSCROLL&(1<<i))
1650 38 numBits++;
1651 190 }
1652
1653 // Shouldn't happen...
1654
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(numBits==0)
1655 return bosCIRCLE;
1656
1657 // Pick a bit
1658 38 bitCounter=zc_rand()%numBits+1;
1659
1660
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 for(int32_t i=0; i<bosMAX; i++)
1661 {
1662 // If this bit is set, decrement the bit counter
1663
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38 times.
38 if(COOLSCROLL&(1<<i))
1664 38 bitCounter--;
1665
1666 // When the counter hits 0, return a value based on
1667 // which bit it stopped on.
1668 // Reminder: enum {bosCIRCLE=0, bosOVAL, bosTRIANGLE, bosSMAS, bosFADEBLACK, bosMAX};
1669
1/2
✓ Branch 0 taken 38 times.
✗ Branch 1 not taken.
38 if(bitCounter==0)
1670 38 return i;
1671 }
1672
1673 // Shouldn't be necessary, but the compiler might complain, at least
1674 return bosCIRCLE;
1675 38 }
1676
1677 8 void close_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1678 {
1679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1680
1681 8 int32_t w=256, h=224;
1682 8 int32_t blockrows=28, blockcolumns=32;
1683 8 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1684
1685
2/2
✓ Branch 0 taken 224 times.
✓ Branch 1 taken 8 times.
232 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1686 {
1687
2/2
✓ Branch 0 taken 7168 times.
✓ Branch 1 taken 224 times.
7392 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1688 {
1689
2/2
✓ Branch 0 taken 3738 times.
✓ Branch 1 taken 3430 times.
7168 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1690 7168 }
1691 224 }
1692
1693 8 black_opening_count = 66;
1694 8 black_opening_x = x;
1695 8 black_opening_y = y;
1696 8 lensclk = 0;
1697 //black_opening_shape=(black_opening_shape+1)%bosMAX;
1698
1699
1700
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(black_opening_shape == bosFADEBLACK)
1701 {
1702 refreshTints();
1703 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1704 }
1705
1/2
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
8 if(wait)
1706 {
1707 FFCore.warpScriptCheck();
1708 for(int32_t i=0; i<66; i++)
1709 {
1710 draw_screen(tmpscr);
1711 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1712 syskeys();
1713 advanceframe(true);
1714
1715 if(Quit)
1716 {
1717 break;
1718 }
1719 }
1720 }
1721 8 }
1722
1723 30 void open_black_opening(int32_t x, int32_t y, bool wait, int32_t shape)
1724 {
1725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 30 times.
30 black_opening_shape= (shape>-1 ? shape : choose_opening_shape());
1726
1727 30 int32_t w=256, h=224;
1728 30 int32_t blockrows=28, blockcolumns=32;
1729 30 int32_t xoffset=(x-(w/2))/8, yoffset=(y-(h/2))/8;
1730
1731
2/2
✓ Branch 0 taken 840 times.
✓ Branch 1 taken 30 times.
870 for(int32_t blockrow=0; blockrow<blockrows; ++blockrow) //30
1732 {
1733
2/2
✓ Branch 0 taken 26880 times.
✓ Branch 1 taken 840 times.
27720 for(int32_t blockcolumn=0; blockcolumn<blockcolumns; ++blockcolumn) //40
1734 {
1735
2/2
✓ Branch 0 taken 11253 times.
✓ Branch 1 taken 15627 times.
26880 screen_triangles[blockrow][blockcolumn]=zc_max(abs(int32_t(double(blockcolumns-1)/2-blockcolumn+xoffset)),abs(int32_t(double(blockrows-1)/2-blockrow+yoffset)))|0x0100|((blockrow-yoffset<blockrows/2)?0:0x8000)|((blockcolumn-xoffset<blockcolumns/2)?0x4000:0);
1736 26880 }
1737 840 }
1738
1739 30 black_opening_count = -66;
1740 30 black_opening_x = x;
1741 30 black_opening_y = y;
1742 30 lensclk = 0;
1743
1/2
✓ Branch 0 taken 30 times.
✗ Branch 1 not taken.
30 if(black_opening_shape == bosFADEBLACK)
1744 {
1745 refreshTints();
1746 memcpy(tempblackpal, RAMpal, sizeof(RAMpal)); //Store palette in temp palette for fade effect
1747 }
1748
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 25 times.
30 if(wait)
1749 {
1750 25 FFCore.warpScriptCheck();
1751
2/2
✓ Branch 0 taken 25 times.
✓ Branch 1 taken 1650 times.
1675 for(int32_t i=0; i<66; i++)
1752 {
1753 1650 draw_screen(tmpscr);
1754 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
1755 1650 syskeys();
1756 1650 advanceframe(true);
1757
1758
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1650 times.
1650 if(Quit)
1759 {
1760 break;
1761 }
1762 1650 }
1763 25 }
1764 30 }
1765
1766 2508 void black_opening(BITMAP *dest,int32_t x,int32_t y,int32_t a,int32_t max_a)
1767 {
1768 2508 clear_to_color(tmp_scr,BLACK);
1769 2508 int32_t w=256, h=224;
1770
1771
1/6
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 2508 times.
2508 switch(black_opening_shape)
1772 {
1773 case bosOVAL:
1774 {
1775 double new_w=(w/2)+abs(w/2-x);
1776 double new_h=(h/2)+abs(h/2-y);
1777 double b=sqrt(((new_w*new_w)/4)+(new_h*new_h));
1778 ellipsefill(tmp_scr,x,y,int32_t(2*a*b/max_a)/8*8,int32_t(a*b/max_a)/8*8,0);
1779 break;
1780 }
1781
1782 case bosTRIANGLE:
1783 {
1784 double new_w=(w/2)+abs(w/2-x);
1785 double new_h=(h/2)+abs(h/2-y);
1786 double r=a*(new_w*sqrt((double)3)+new_h)/max_a;
1787 double P2= (PI/2);
1788 double P23=(2*PI/3);
1789 double P43=(4*PI/3);
1790 double Pa= (-4*PI*a/(3*max_a));
1791 double angle=P2+Pa;
1792 double a0=angle;
1793 double a2=angle+P23;
1794 double a4=angle+P43;
1795 triangle(tmp_scr, x+int32_t(zc::math::Cos(a0)*r), y-int32_t(zc::math::Sin(a0)*r),
1796 x+int32_t(zc::math::Cos(a2)*r), y-int32_t(zc::math::Sin(a2)*r),
1797 x+int32_t(zc::math::Cos(a4)*r), y-int32_t(zc::math::Sin(a4)*r),
1798 0);
1799 break;
1800 }
1801
1802 case bosSMAS:
1803 {
1804 int32_t distance=zc_max(abs(w/2-x),abs(h/2-y))/8;
1805
1806 for(int32_t blockrow=0; blockrow<28; ++blockrow) //30
1807 {
1808 for(int32_t linerow=0; linerow<8; ++linerow)
1809 {
1810 qword *triangleline=(qword*)(tmp_scr->line[(blockrow*8+linerow)]);
1811
1812 for(int32_t blockcolumn=0; blockcolumn<32; ++blockcolumn) //40
1813 {
1814 *triangleline=triangles[(screen_triangles[blockrow][blockcolumn]&0xC000)>>14]
1815 [zc_min(zc_max((((31+distance)*(max_a-a)/max_a)+((screen_triangles[blockrow][blockcolumn]&0x0FFF)-0x0100)-(15+distance)),0),15)]
1816 [linerow];
1817 ++triangleline;
1818
1819 if(linerow==0)
1820 {
1821 }
1822 }
1823 }
1824 }
1825
1826 break;
1827 }
1828
1829 case bosFADEBLACK:
1830 {
1831 if(black_opening_count<0)
1832 {
1833 black_fade(zc_min(-black_opening_count,63));
1834 }
1835 else if(black_opening_count>0)
1836 {
1837 black_fade(63-zc_max(black_opening_count-3,0));
1838 }
1839 else black_fade(0);
1840 return; //no blitting from tmp_scr!
1841 }
1842
1843 2508 case bosCIRCLE:
1844 default:
1845 {
1846 2508 double new_w=(w/2)+abs(w/2-x);
1847 2508 double new_h=(h/2)+abs(h/2-y);
1848 2508 int32_t r=int32_t(sqrt((new_w*new_w)+(new_h*new_h))*a/max_a);
1849 //circlefill(tmp_scr,x,y,a<<3,0);
1850 2508 circlefill(tmp_scr,x,y,r,0);
1851 2508 break;
1852 }
1853 }
1854
1855 2508 masked_blit(tmp_scr,dest,0,0,0,0,320,240);
1856 2508 }
1857
1858
1859 void black_fade(int32_t fadeamnt)
1860 {
1861 for(int32_t i=0; i < 0xEF; i++)
1862 {
1863 RAMpal[i].r = vbound(tempblackpal[i].r-fadeamnt,0,63);
1864 RAMpal[i].g = vbound(tempblackpal[i].g-fadeamnt,0,63);
1865 RAMpal[i].b = vbound(tempblackpal[i].b-fadeamnt,0,63);
1866 }
1867
1868 refreshpal = true;
1869 }
1870
1871 //----------------------------------------------------------------
1872
1873 92604 bool item_disabled(int32_t item) //is this item disabled?
1874 {
1875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 92604 times.
92604 return (item>=0 && game->items_off[item] != 0);
1876 }
1877
1878 174678 bool can_use_item(int32_t item_type, int32_t item) //can Hero use this item?
1879 {
1880
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 174678 times.
174678 if(current_item(item_type, true) >=item)
1881 {
1882 return true;
1883 }
1884
1885 174678 return false;
1886 174678 }
1887
1888 742192 bool has_item(int32_t item_type, int32_t it) //does Hero possess this item?
1889 {
1890
5/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 118365 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 37388 times.
✓ Branch 6 taken 444894 times.
✓ Branch 7 taken 140814 times.
✓ Branch 8 taken 731 times.
742192 switch(item_type)
1891 {
1892 case itype_bomb:
1893 case itype_sbomb:
1894 {
1895 int32_t itemid = getItemID(itemsbuf, item_type, it);
1896
1897 if(itemid == -1)
1898 return false;
1899
1900 return (game->get_item(itemid));
1901 }
1902
1903 case itype_clock:
1904 {
1905 118365 int32_t itemid = getItemID(itemsbuf, item_type, it);
1906
1907
2/4
✓ Branch 0 taken 118365 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 118365 times.
✗ Branch 3 not taken.
118365 if(itemid != -1 && (itemsbuf[itemid].flags & ITEM_FLAG1)) //Active clock
1908 return (game->get_item(itemid));
1909 118365 return Hero.getClock()?1:0;
1910 }
1911
1912 case itype_key:
1913 return (game->get_keys()>0);
1914
1915 case itype_magiccontainer:
1916 return (game->get_maxmagic()>=game->get_mp_per_block());
1917
1918 case itype_triforcepiece: //it: -2=any, -1=current level, other=that level
1919 {
1920
1/3
✓ Branch 0 taken 37388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
37388 switch(it)
1921 {
1922 case -2:
1923 {
1924 for(int32_t i=0; i<MAXLEVELS; i++)
1925 {
1926 if(game->lvlitems[i]&liTRIFORCE)
1927 {
1928 return true;
1929 }
1930 }
1931
1932 return false;
1933 }
1934
1935 case -1:
1936 return (game->lvlitems[dlevel]&liTRIFORCE);
1937
1938 default:
1939
2/4
✓ Branch 0 taken 37388 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 37388 times.
37388 if(it>=0&&it<MAXLEVELS)
1940 {
1941 37388 return (game->lvlitems[it]&liTRIFORCE);
1942 }
1943
1944 break;
1945 }
1946
1947 return 0;
1948 }
1949
1950 case itype_map: //it: -2=any, -1=current level, other=that level
1951 {
1952
1/3
✓ Branch 0 taken 444894 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
444894 switch(it)
1953 {
1954 case -2:
1955 {
1956 for(int32_t i=0; i<MAXLEVELS; i++)
1957 {
1958 if(game->lvlitems[i]&liMAP)
1959 {
1960 return true;
1961 }
1962 }
1963
1964 return false;
1965 }
1966
1967 case -1:
1968 return (game->lvlitems[dlevel]&liMAP)!=0;
1969
1970 default:
1971
2/4
✓ Branch 0 taken 444894 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 444894 times.
444894 if(it>=0&&it<MAXLEVELS)
1972 {
1973 444894 return (game->lvlitems[it]&liMAP)!=0;
1974 }
1975
1976 break;
1977 }
1978
1979 return 0;
1980 }
1981
1982 case itype_compass: //it: -2=any, -1=current level, other=that level
1983 {
1984
1/3
✓ Branch 0 taken 140814 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
140814 switch(it)
1985 {
1986 case -2:
1987 {
1988 for(int32_t i=0; i<MAXLEVELS; i++)
1989 {
1990 if(game->lvlitems[i]&liCOMPASS)
1991 {
1992 return true;
1993 }
1994 }
1995
1996 return false;
1997 }
1998
1999 case -1:
2000 return (game->lvlitems[dlevel]&liCOMPASS)!=0;
2001
2002 default:
2003
2/4
✓ Branch 0 taken 140814 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 140814 times.
✗ Branch 3 not taken.
140814 if(it>=0&&it<MAXLEVELS)
2004 {
2005 140814 return (game->lvlitems[it]&liCOMPASS)!=0;
2006 }
2007
2008 break;
2009 }
2010 return 0;
2011 }
2012
2013 case itype_bosskey: //it: -2=any, -1=current level, other=that level
2014 {
2015
1/3
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
731 switch(it)
2016 {
2017 case -2:
2018 {
2019 for(int32_t i=0; i<MAXLEVELS; i++)
2020 {
2021 if(game->lvlitems[i]&liBOSSKEY)
2022 {
2023 return true;
2024 }
2025 }
2026
2027 return false;
2028 }
2029
2030 case -1:
2031 return (game->lvlitems[dlevel]&liBOSSKEY)?1:0;
2032
2033 default:
2034
2/4
✓ Branch 0 taken 731 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 731 times.
731 if(it>=0&&it<MAXLEVELS)
2035 {
2036 731 return (game->lvlitems[it]&liBOSSKEY)?1:0;
2037 }
2038 break;
2039 }
2040 return 0;
2041 }
2042
2043 default:
2044 //it=(1<<(it-1));
2045 /*if (item_type>=itype_max)
2046 {
2047 system_pal();
2048 jwin_alert("Error","has_item exception",NULL,NULL,"O&K",NULL,'k',0,lfont);
2049 game_pal();
2050
2051 return false;
2052 }*/
2053 int32_t itemid = getItemID(itemsbuf, item_type, it);
2054
2055 if(itemid == -1)
2056 return false;
2057
2058 return game->get_item(itemid);
2059 }
2060 742192 }
2061
2062
2063 2050367 int32_t current_item(int32_t item_type, bool checkenabled) //item currently being used
2064 {
2065
9/9
✓ Branch 0 taken 118365 times.
✓ Branch 1 taken 1103447 times.
✓ Branch 2 taken 118365 times.
✓ Branch 3 taken 118365 times.
✓ Branch 4 taken 118365 times.
✓ Branch 5 taken 118365 times.
✓ Branch 6 taken 118365 times.
✓ Branch 7 taken 118365 times.
✓ Branch 8 taken 118365 times.
2050367 switch(item_type)
2066 {
2067 case itype_clock:
2068 {
2069 118365 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2070
2071
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 118365 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
118365 if(maxid != -1 && (itemsbuf[maxid].flags & ITEM_FLAG1)) //Active clock
2072 return itemsbuf[maxid].fam_type;
2073
2074 118365 return has_item(itype_clock,1) ? 1 : 0;
2075 }
2076
2077 case itype_key:
2078 118365 return game->get_keys();
2079
2080 case itype_lkey:
2081 118365 return game->lvlkeys[get_dlevel()];
2082
2083 case itype_magiccontainer:
2084 118365 return game->get_maxmagic()/game->get_mp_per_block();
2085
2086 case itype_triforcepiece:
2087 {
2088 118365 int32_t count=0;
2089
2090
2/2
✓ Branch 0 taken 60602880 times.
✓ Branch 1 taken 118365 times.
60721245 for(int32_t i=0; i<MAXLEVELS; i++)
2091 {
2092 60602880 count+=(game->lvlitems[i]&liTRIFORCE)?1:0;
2093 60602880 }
2094
2095 118365 return count;
2096 }
2097
2098 case itype_map:
2099 {
2100 118365 int32_t count=0;
2101
2102
2/2
✓ Branch 0 taken 60602880 times.
✓ Branch 1 taken 118365 times.
60721245 for(int32_t i=0; i<MAXLEVELS; i++)
2103 {
2104 60602880 count+=(game->lvlitems[i]&liMAP)?1:0;
2105 60602880 }
2106
2107 118365 return count;
2108 }
2109
2110 case itype_compass:
2111 {
2112 118365 int32_t count=0;
2113
2114
2/2
✓ Branch 0 taken 60602880 times.
✓ Branch 1 taken 118365 times.
60721245 for(int32_t i=0; i<MAXLEVELS; i++)
2115 {
2116 60602880 count+=(game->lvlitems[i]&liCOMPASS)?1:0;
2117 60602880 }
2118
2119 118365 return count;
2120 }
2121
2122 case itype_bosskey:
2123 {
2124 118365 int32_t count=0;
2125
2126
2/2
✓ Branch 0 taken 60602880 times.
✓ Branch 1 taken 118365 times.
60721245 for(int32_t i=0; i<MAXLEVELS; i++)
2127 {
2128 60602880 count+=(game->lvlitems[i]&liBOSSKEY)?1:0;
2129 60602880 }
2130
2131 118365 return count;
2132 }
2133
2134 default:
2135 1103447 int32_t maxid = getHighestLevelOfFamily(game, itemsbuf, item_type, checkenabled);
2136
2137
2/2
✓ Branch 0 taken 53182 times.
✓ Branch 1 taken 1050265 times.
1103447 if(maxid == -1)
2138 1050265 return 0;
2139
2140 53182 return itemsbuf[maxid].fam_type;
2141 }
2142 2050367 }
2143
2144 1875689 int32_t current_item(int32_t item_type) //item currently being used
2145 {
2146 1875689 return current_item(item_type, true);
2147 }
2148
2149 7 std::map<int32_t, int32_t> itemcache;
2150
2151 // Not actually used by anything at the moment...
2152 void removeFromItemCache(int32_t itemid)
2153 {
2154 itemcache.erase(itemid);
2155 }
2156
2157 389 void flushItemCache()
2158 {
2159 389 itemcache.clear();
2160
2161 //also fix the active subscreen if items were deleted -DD
2162
1/2
✓ Branch 0 taken 389 times.
✗ Branch 1 not taken.
389 if(game != NULL)
2163 {
2164 389 verifyBothWeapons();
2165 389 load_Sitems(&QMisc);
2166 389 }
2167 389 }
2168
2169 // This is used often, so it should be as direct as possible.
2170 65099272 int32_t _c_item_id_internal(int32_t itemtype, bool checkmagic, bool jinx_check)
2171 {
2172
2/2
✓ Branch 0 taken 64170158 times.
✓ Branch 1 taken 929114 times.
65099272 if(jinx_check)
2173 {
2174
3/4
✓ Branch 0 taken 758466 times.
✓ Branch 1 taken 170648 times.
✓ Branch 2 taken 758466 times.
✗ Branch 3 not taken.
929114 if(!(HeroSwordClk() || HeroItemClk()))
2175 758466 jinx_check = false; //not jinxed
2176 929114 }
2177
4/4
✓ Branch 0 taken 64772696 times.
✓ Branch 1 taken 326576 times.
✓ Branch 2 taken 169976 times.
✓ Branch 3 taken 64602720 times.
65099272 if(itemtype!=itype_ring && !jinx_check) // Rings must always be checked, as must jinx checks...
2178 {
2179 64602720 std::map<int32_t,int32_t>::iterator res = itemcache.find(itemtype);
2180
2181
2/2
✓ Branch 0 taken 64404267 times.
✓ Branch 1 taken 198453 times.
64602720 if(res != itemcache.end())
2182 64404267 return res->second;
2183 198453 }
2184
2185 695005 int32_t result = -1;
2186 695005 int32_t highestlevel = -1;
2187
2188
2/2
✓ Branch 0 taken 177921280 times.
✓ Branch 1 taken 695005 times.
178616285 for(int32_t i=0; i<MAXITEMS; i++)
2189 {
2190
5/6
✓ Branch 0 taken 5558517 times.
✓ Branch 1 taken 172362763 times.
✓ Branch 2 taken 90371 times.
✓ Branch 3 taken 5468146 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 90371 times.
177921280 if(game->get_item(i) && itemsbuf[i].family==itemtype && !item_disabled(i))
2191 {
2192
4/4
✓ Branch 0 taken 37927 times.
✓ Branch 1 taken 52444 times.
✓ Branch 2 taken 5502 times.
✓ Branch 3 taken 84869 times.
90371 if((checkmagic || itemtype == itype_ring) && itemtype != itype_magicring)
2193 {
2194 //printf("Checkmagic for %d: %d (%d %d)\n",i,checkmagiccost(i),itemsbuf[i].magic*game->get_magicdrainrate(),game->get_magic());
2195
2/2
✓ Branch 0 taken 84868 times.
✓ Branch 1 taken 1 times.
84869 if(!checkmagiccost(i))
2196 {
2197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if ( !get_bit(quest_rules,qr_NEVERDISABLEAMMOONSUBSCREEN) ) continue; //don't make items with a magic cost vanish!! -Z
2198 }
2199 84868 }
2200
6/6
✓ Branch 0 taken 81442 times.
✓ Branch 1 taken 8928 times.
✓ Branch 2 taken 1322 times.
✓ Branch 3 taken 7606 times.
✓ Branch 4 taken 7606 times.
✓ Branch 5 taken 1322 times.
90370 if(jinx_check && (usesSwordJinx(i) ? HeroSwordClk() : HeroItemClk()))
2201 {
2202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1322 times.
1322 if(!(itemsbuf[i].flags & ITEM_JINX_IMMUNE))
2203 1322 continue;
2204 }
2205
2206
2/2
✓ Branch 0 taken 2286 times.
✓ Branch 1 taken 86762 times.
89048 if(itemsbuf[i].fam_type >= highestlevel)
2207 {
2208 86762 highestlevel = itemsbuf[i].fam_type;
2209 86762 result=i;
2210 86762 }
2211 89048 }
2212 177919957 }
2213
2214
2/2
✓ Branch 0 taken 170648 times.
✓ Branch 1 taken 524357 times.
695005 if(!jinx_check) //Can't cache jinx_check results
2215 524357 itemcache[itemtype] = result;
2216 695005 return result;
2217 65099272 }
2218
2219 // 'jinx_check' indicates that the highest level item *immune to jinxes* should be returned.
2220 64930777 int32_t current_item_id(int32_t itemtype, bool checkmagic, bool jinx_check)
2221 {
2222 64930777 auto ret = _c_item_id_internal(itemtype,checkmagic,jinx_check);
2223
2/2
✓ Branch 0 taken 760619 times.
✓ Branch 1 taken 64170158 times.
64930777 if(!jinx_check) //If not already a jinx-immune-only check...
2224 {
2225 //And the player IS jinxed...
2226
3/4
✓ Branch 0 taken 64001663 times.
✓ Branch 1 taken 168495 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64001663 times.
64170158 if(HeroSwordClk() || HeroItemClk())
2227 {
2228 //Then do a jinx-immune-only check here
2229 168495 auto ret2 = _c_item_id_internal(itemtype,checkmagic,true);
2230 //And *IF IT FINDS A VALID ITEM*, return that one instead! -Em
2231 //Should NOT need a compat rule, as this should always return -1 in old quests.
2232
2/2
✓ Branch 0 taken 4313 times.
✓ Branch 1 taken 164182 times.
168495 if(ret2 > -1) return ret2;
2233 164182 }
2234 64165845 }
2235 64926464 return ret;
2236 64930777 }
2237 413041 int32_t current_item_power(int32_t itemtype)
2238 {
2239 413041 int32_t result = current_item_id(itemtype,true);
2240
2/2
✓ Branch 0 taken 375635 times.
✓ Branch 1 taken 37406 times.
413041 return (result<0) ? 0 : itemsbuf[result].power;
2241 }
2242
2243 int32_t heart_container_id()
2244 {
2245 for(int32_t i=0; i<MAXITEMS; i++)
2246 {
2247 if(itemsbuf[i].family == itype_heartcontainer)
2248 {
2249 return i;
2250 }
2251 }
2252 return -1;
2253 }
2254
2255 118365 int32_t item_tile_mod()
2256 {
2257 118365 int32_t tile=0;
2258
2259
2/2
✓ Branch 0 taken 24888 times.
✓ Branch 1 taken 93477 times.
118365 if(game->get_bombs())
2260 {
2261 93477 int32_t itemid = current_item_id(itype_bomb,false);
2262
2/4
✓ Branch 0 taken 93477 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 93477 times.
93477 if(itemid > -1 && checkbunny(itemid))
2263 93477 tile+=itemsbuf[itemid].ltm;
2264 93477 }
2265
2266
2/2
✓ Branch 0 taken 107571 times.
✓ Branch 1 taken 10794 times.
118365 if(game->get_sbombs())
2267 {
2268 10794 int32_t itemid = current_item_id(itype_sbomb,false);
2269
3/4
✓ Branch 0 taken 4127 times.
✓ Branch 1 taken 6667 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4127 times.
10794 if(itemid > -1 && checkbunny(itemid))
2270 4127 tile+=itemsbuf[itemid].ltm;
2271 10794 }
2272
2273
2/2
✓ Branch 0 taken 116336 times.
✓ Branch 1 taken 2029 times.
118365 if(current_item(itype_clock))
2274 {
2275 2029 int32_t itemid =
2276
1/2
✓ Branch 0 taken 2029 times.
✗ Branch 1 not taken.
2029 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2277 ? iClock
2278 : getHighestLevelEvenUnowned(itemsbuf, itype_clock);
2279
2/4
✓ Branch 0 taken 2029 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 2029 times.
2029 if(itemid > -1 && checkbunny(itemid))
2280 2029 tile+=itemsbuf[itemid].ltm;
2281 2029 }
2282
2283
2/2
✓ Branch 0 taken 101124 times.
✓ Branch 1 taken 17241 times.
118365 if(current_item(itype_key))
2284 {
2285 17241 int32_t itemid =
2286
1/2
✓ Branch 0 taken 17241 times.
✗ Branch 1 not taken.
17241 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2287 ? iKey
2288 : getHighestLevelEvenUnowned(itemsbuf, itype_key);
2289
2/4
✓ Branch 0 taken 17241 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 17241 times.
17241 if(itemid > -1 && checkbunny(itemid))
2290 17241 tile+=itemsbuf[itemid].ltm;
2291 17241 }
2292
2293
1/2
✓ Branch 0 taken 118365 times.
✗ Branch 1 not taken.
118365 if(current_item(itype_lkey))
2294 {
2295 int32_t itemid =
2296 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2297 ? iLevelKey
2298 : getHighestLevelEvenUnowned(itemsbuf, itype_lkey);
2299 if(itemid > -1 && checkbunny(itemid))
2300 tile+=itemsbuf[itemid].ltm;
2301 }
2302
2303
2/2
✓ Branch 0 taken 46697 times.
✓ Branch 1 taken 71668 times.
118365 if(current_item(itype_map))
2304 {
2305 71668 int32_t itemid =
2306
1/2
✓ Branch 0 taken 71668 times.
✗ Branch 1 not taken.
71668 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2307 ? iMap
2308 : getHighestLevelEvenUnowned(itemsbuf, itype_map);
2309
2/4
✓ Branch 0 taken 71668 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 71668 times.
71668 if(itemid > -1 && checkbunny(itemid))
2310 71668 tile+=itemsbuf[itemid].ltm;
2311 71668 }
2312
2313
2/2
✓ Branch 0 taken 41504 times.
✓ Branch 1 taken 76861 times.
118365 if(current_item(itype_compass))
2314 {
2315 76861 int32_t itemid =
2316
1/2
✓ Branch 0 taken 76861 times.
✗ Branch 1 not taken.
76861 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2317 ? iCompass
2318 : getHighestLevelEvenUnowned(itemsbuf, itype_compass);
2319
2/4
✓ Branch 0 taken 76861 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 76861 times.
76861 if(itemid > -1 && checkbunny(itemid))
2320 76861 tile+=itemsbuf[itemid].ltm;
2321 76861 }
2322
2323
1/2
✓ Branch 0 taken 118365 times.
✗ Branch 1 not taken.
118365 if(current_item(itype_bosskey))
2324 {
2325 int32_t itemid =
2326 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2327 ? iBossKey
2328 : getHighestLevelEvenUnowned(itemsbuf, itype_bosskey);
2329 if(itemid > -1 && checkbunny(itemid))
2330 tile+=itemsbuf[itemid].ltm;
2331 }
2332
2333
1/2
✓ Branch 0 taken 118365 times.
✗ Branch 1 not taken.
118365 if(current_item(itype_magiccontainer))
2334 {
2335 int32_t itemid =
2336 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2337 ? iMagicC
2338 : getHighestLevelEvenUnowned(itemsbuf, itype_magiccontainer);
2339 if(itemid > -1 && checkbunny(itemid))
2340 tile+=itemsbuf[itemid].ltm;
2341 }
2342
2343
2/2
✓ Branch 0 taken 42507 times.
✓ Branch 1 taken 75858 times.
118365 if(current_item(itype_triforcepiece))
2344 {
2345 75858 int32_t itemid =
2346
1/2
✓ Branch 0 taken 75858 times.
✗ Branch 1 not taken.
75858 get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS)
2347 ? iTriforce
2348 : getHighestLevelEvenUnowned(itemsbuf, itype_triforcepiece);
2349
2/4
✓ Branch 0 taken 75858 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 75858 times.
75858 if(itemid > -1 && checkbunny(itemid))
2350 75858 tile+=itemsbuf[itemid].ltm;
2351 75858 }
2352
2353
2/2
✓ Branch 0 taken 118365 times.
✓ Branch 1 taken 60602880 times.
60721245 for(int32_t i=0; i<itype_max; i++)
2354 {
2355
2/2
✓ Branch 0 taken 55115776 times.
✓ Branch 1 taken 5487104 times.
60602880 if(!get_bit(quest_rules, qr_HARDCODED_LITEM_LTMS))
2356 {
2357
2/2
✓ Branch 0 taken 107170 times.
✓ Branch 1 taken 5379934 times.
5487104 switch(i)
2358 {
2359 case itype_bomb:
2360 case itype_sbomb:
2361 case itype_clock:
2362 case itype_key:
2363 case itype_lkey:
2364 case itype_map:
2365 case itype_compass:
2366 case itype_bosskey:
2367 case itype_magiccontainer:
2368 case itype_triforcepiece:
2369 107170 continue; //already handled
2370 }
2371 5379934 }
2372 60495710 int32_t itemid = current_item_id(i,false);
2373
2/2
✓ Branch 0 taken 60377345 times.
✓ Branch 1 taken 118365 times.
60495710 if(i == itype_shield)
2374 118365 itemid = getCurrentShield(false);
2375
2376
3/4
✓ Branch 0 taken 806213 times.
✓ Branch 1 taken 59689497 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 806213 times.
60495710 if(itemid < 0 || !checkbunny(itemid))
2377 59689497 continue;
2378
2379 806213 itemdata const& itm = itemsbuf[itemid];
2380
2381
2/2
✓ Branch 0 taken 687848 times.
✓ Branch 1 taken 118365 times.
806213 switch(itm.family)
2382 {
2383 case itype_shield:
2384
1/2
✓ Branch 0 taken 118365 times.
✗ Branch 1 not taken.
118365 if(itm.flags & ITEM_FLAG9) //active shield
2385 {
2386 if(!usingActiveShield(itemid))
2387 {
2388 tile+=itm.misc6; //'Inactive PTM'
2389 continue;
2390 }
2391 }
2392 118365 break;
2393 }
2394
2395 806213 tile+=itm.ltm;
2396 806213 }
2397
2398 118365 return tile;
2399 }
2400
2401 118365 int32_t bunny_tile_mod()
2402 {
2403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 118365 times.
118365 if(Hero.BunnyClock())
2404 {
2405 return game->get_bunny_ltm();
2406 }
2407 118365 return 0;
2408 118365 }
2409
2410 // Hints are drawn on a separate layer to combo reveals.
2411 void draw_lens_under(BITMAP *dest, bool layer)
2412 {
2413 //Lens flag 1: Replacement for qr_LENSHINTS; if set, lens will show hints. Does nothing if flag 2 is set.
2414 //Lens flag 2: Disable "hints", prevent rendering of Secret Combos
2415 //Lens flag 3: Don't show armos/chest/dive items
2416 //Lens flag 4: Show Raft Paths
2417 //Lens flag 5: Show Invisible Enemies
2418 bool hints = (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2) ? false : (layer && (itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG1));
2419
2420 int32_t strike_hint_table[11]=
2421 {
2422 mfARROW, mfBOMB, mfBRANG, mfWANDMAGIC,
2423 mfSWORD, mfREFMAGIC, mfHOOKSHOT,
2424 mfREFFIREBALL, mfHAMMER, mfSWORDBEAM, mfWAND
2425 };
2426
2427 // int32_t page = tmpscr->cpage;
2428 {
2429 int32_t blink_rate=((get_bit(quest_rules,qr_EPILEPSY) || epilepsyFlashReduction)?6:1);
2430 // int32_t temptimer=0;
2431 int32_t tempitem, tempweapon=0;
2432 strike_hint=strike_hint_table[strike_hint_counter];
2433
2434 if(strike_hint_timer>32)
2435 {
2436 strike_hint_timer=0;
2437 strike_hint_counter=((strike_hint_counter+1)%11);
2438 }
2439
2440 ++strike_hint_timer;
2441
2442 for(int32_t i=0; i<176; i++)
2443 {
2444 int32_t x = (i & 15) << 4;
2445 int32_t y = (i & 0xF0) + playing_field_offset;
2446 int32_t tempitemx=-16, tempitemy=-16;
2447 int32_t tempweaponx=-16, tempweapony=-16;
2448
2449 for(int32_t iter=0; iter<2; ++iter)
2450 {
2451 int32_t checkflag=0;
2452
2453 if(iter==0)
2454 {
2455 checkflag=combobuf[tmpscr->data[i]].flag;
2456 }
2457 else
2458 {
2459 checkflag=tmpscr->sflag[i];
2460 }
2461
2462 if(checkflag==mfSTRIKE)
2463 {
2464 if(!hints)
2465 {
2466 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTRIKE],tmpscr->secretcset[sSTRIKE]);
2467 }
2468 else
2469 {
2470 checkflag = strike_hint;
2471 }
2472 }
2473
2474 switch(checkflag)
2475 {
2476 case 0:
2477 case mfZELDA:
2478 case mfPUSHED:
2479 case mfENEMY0:
2480 case mfENEMY1:
2481 case mfENEMY2:
2482 case mfENEMY3:
2483 case mfENEMY4:
2484 case mfENEMY5:
2485 case mfENEMY6:
2486 case mfENEMY7:
2487 case mfENEMY8:
2488 case mfENEMY9:
2489 case mfSINGLE:
2490 case mfSINGLE16:
2491 case mfNOENEMY:
2492 case mfTRAP_H:
2493 case mfTRAP_V:
2494 case mfTRAP_4:
2495 case mfTRAP_LR:
2496 case mfTRAP_UD:
2497 case mfNOGROUNDENEMY:
2498 case mfNOBLOCKS:
2499 case mfSCRIPT1:
2500 case mfSCRIPT2:
2501 case mfSCRIPT3:
2502 case mfSCRIPT4:
2503 case mfSCRIPT5:
2504 case mfSCRIPT6:
2505 case mfSCRIPT7:
2506 case mfSCRIPT8:
2507 case mfSCRIPT9:
2508 case mfSCRIPT10:
2509 case mfSCRIPT11:
2510 case mfSCRIPT12:
2511 case mfSCRIPT13:
2512 case mfSCRIPT14:
2513 case mfSCRIPT15:
2514 case mfSCRIPT16:
2515 case mfSCRIPT17:
2516 case mfSCRIPT18:
2517 case mfSCRIPT19:
2518 case mfSCRIPT20:
2519 case mfPITHOLE:
2520 case mfPITFALLFLOOR:
2521 case mfLAVA:
2522 case mfICE:
2523 case mfICEDAMAGE:
2524 case mfDAMAGE1:
2525 case mfDAMAGE2:
2526 case mfDAMAGE4:
2527 case mfDAMAGE8:
2528 case mfDAMAGE16:
2529 case mfDAMAGE32:
2530 case mfFREEZEALL:
2531 case mfFREZEALLANSFFCS:
2532 case mfFREEZEFFCSOLY:
2533 case mfSCRITPTW1TRIG:
2534 case mfSCRITPTW2TRIG:
2535 case mfSCRITPTW3TRIG:
2536 case mfSCRITPTW4TRIG:
2537 case mfSCRITPTW5TRIG:
2538 case mfSCRITPTW6TRIG:
2539 case mfSCRITPTW7TRIG:
2540 case mfSCRITPTW8TRIG:
2541 case mfSCRITPTW9TRIG:
2542 case mfSCRITPTW10TRIG:
2543 case mfTROWEL:
2544 case mfTROWELNEXT:
2545 case mfTROWELSPECIALITEM:
2546 case mfSLASHPOT:
2547 case mfLIFTPOT:
2548 case mfLIFTORSLASH:
2549 case mfLIFTROCK:
2550 case mfLIFTROCKHEAVY:
2551 case mfDROPITEM:
2552 case mfSPECIALITEM:
2553 case mfDROPKEY:
2554 case mfDROPLKEY:
2555 case mfDROPCOMPASS:
2556 case mfDROPMAP:
2557 case mfDROPBOSSKEY:
2558 case mfSPAWNNPC:
2559 case mfSWITCHHOOK:
2560 case mfSIDEVIEWLADDER:
2561 case mfSIDEVIEWPLATFORM:
2562 case mfNOENEMYSPAWN:
2563 case mfENEMYALL:
2564 case mfNOMIRROR:
2565 case mfUNSAFEGROUND:
2566 case mf168:
2567 case mf169:
2568 case mf170:
2569 case mf171:
2570 case mf172:
2571 case mf173:
2572 case mf174:
2573 case mf175:
2574 case mf176:
2575 case mf177:
2576 case mf178:
2577 case mf179:
2578 case mf180:
2579 case mf181:
2580 case mf182:
2581 case mf183:
2582 case mf184:
2583 case mf185:
2584 case mf186:
2585 case mf187:
2586 case mf188:
2587 case mf189:
2588 case mf190:
2589 case mf191:
2590 case mf192:
2591 case mf193:
2592 case mf194:
2593 case mf195:
2594 case mf196:
2595 case mf197:
2596 case mf198:
2597 case mf199:
2598 case mf200:
2599 case mf201:
2600 case mf202:
2601 case mf203:
2602 case mf204:
2603 case mf205:
2604 case mf206:
2605 case mf207:
2606 case mf208:
2607 case mf209:
2608 case mf210:
2609 case mf211:
2610 case mf212:
2611 case mf213:
2612 case mf214:
2613 case mf215:
2614 case mf216:
2615 case mf217:
2616 case mf218:
2617 case mf219:
2618 case mf220:
2619 case mf221:
2620 case mf222:
2621 case mf223:
2622 case mf224:
2623 case mf225:
2624 case mf226:
2625 case mf227:
2626 case mf228:
2627 case mf229:
2628 case mf230:
2629 case mf231:
2630 case mf232:
2631 case mf233:
2632 case mf234:
2633 case mf235:
2634 case mf236:
2635 case mf237:
2636 case mf238:
2637 case mf239:
2638 case mf240:
2639 case mf241:
2640 case mf242:
2641 case mf243:
2642 case mf244:
2643 case mf245:
2644 case mf246:
2645 case mf247:
2646 case mf248:
2647 case mf249:
2648 case mf250:
2649 case mf251:
2650 case mf252:
2651 case mf253:
2652 case mf254:
2653 case mfEXTENDED:
2654 break;
2655
2656 case mfPUSHUD:
2657 case mfPUSHLR:
2658 case mfPUSH4:
2659 case mfPUSHU:
2660 case mfPUSHD:
2661 case mfPUSHL:
2662 case mfPUSHR:
2663 case mfPUSHUDNS:
2664 case mfPUSHLRNS:
2665 case mfPUSH4NS:
2666 case mfPUSHUNS:
2667 case mfPUSHDNS:
2668 case mfPUSHLNS:
2669 case mfPUSHRNS:
2670 case mfPUSHUDINS:
2671 case mfPUSHLRINS:
2672 case mfPUSH4INS:
2673 case mfPUSHUINS:
2674 case mfPUSHDINS:
2675 case mfPUSHLINS:
2676 case mfPUSHRINS:
2677 if(!hints && ((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&16))
2678 || ((get_debug() && zc_getkey(KEY_N)) && (frame&16))))
2679 {
2680 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->undercombo,tmpscr->undercset);
2681 }
2682
2683 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2684 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2685 {
2686 if(hints)
2687 {
2688 switch(combobuf[tmpscr->data[i]].type)
2689 {
2690 case cPUSH_HEAVY:
2691 case cPUSH_HW:
2692 tempitem=getItemIDPower(itemsbuf,itype_bracelet,1);
2693 tempitemx=x, tempitemy=y;
2694
2695 if(tempitem>-1)
2696 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2697
2698 break;
2699
2700 case cPUSH_HEAVY2:
2701 case cPUSH_HW2:
2702 tempitem=getItemIDPower(itemsbuf,itype_bracelet,2);
2703 tempitemx=x, tempitemy=y;
2704
2705 if(tempitem>-1)
2706 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2707
2708 break;
2709 }
2710 }
2711 }
2712
2713 break;
2714
2715 case mfWHISTLE:
2716 if(hints)
2717 {
2718 tempitem=getItemID(itemsbuf,itype_whistle,1);
2719
2720 if(tempitem<0) break;
2721
2722 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2723 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2724 {
2725 tempitemx=x;
2726 tempitemy=y;
2727 }
2728
2729 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2730 }
2731
2732 break;
2733
2734 //Why is this here?
2735 case mfFAIRY:
2736 case mfMAGICFAIRY:
2737 case mfALLFAIRY:
2738 if(hints)
2739 {
2740 tempitem=getItemID(itemsbuf, itype_fairy,1);//iFairyMoving;
2741
2742 if(tempitem < 0) break;
2743
2744 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2745 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2746 {
2747 tempitemx=x;
2748 tempitemy=y;
2749 }
2750
2751 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2752 }
2753
2754 break;
2755
2756 case mfBCANDLE:
2757 if(!hints)
2758 {
2759 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBCANDLE],tmpscr->secretcset[sBCANDLE]);
2760 }
2761 else
2762 {
2763 tempitem=getItemID(itemsbuf,itype_candle,1);
2764
2765 if(tempitem<0) break;
2766
2767 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2768 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2769 {
2770 tempitemx=x;
2771 tempitemy=y;
2772 }
2773
2774 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2775 }
2776
2777 break;
2778
2779 case mfRCANDLE:
2780 if(!hints)
2781 {
2782 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sRCANDLE],tmpscr->secretcset[sRCANDLE]);
2783 }
2784 else
2785 {
2786 tempitem=getItemID(itemsbuf,itype_candle,2);
2787
2788 if(tempitem<0) break;
2789
2790 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2791 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2792 {
2793 tempitemx=x;
2794 tempitemy=y;
2795 }
2796
2797 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2798 }
2799
2800 break;
2801
2802 case mfWANDFIRE:
2803 if(!hints)
2804 {
2805 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDFIRE],tmpscr->secretcset[sWANDFIRE]);
2806 }
2807 else
2808 {
2809 tempitem=getItemID(itemsbuf,itype_wand,1);
2810
2811 if(tempitem<0) break;
2812
2813 tempweapon=wFire;
2814
2815 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2816 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2817 {
2818 tempitemx=x;
2819 tempitemy=y;
2820 }
2821 else
2822 {
2823 tempweaponx=x;
2824 tempweapony=y;
2825 }
2826
2827 putweapon(dest,tempweaponx,tempweapony,tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2828 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2829 }
2830
2831 break;
2832
2833 case mfDINSFIRE:
2834 if(!hints)
2835 {
2836 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sDINSFIRE],tmpscr->secretcset[sDINSFIRE]);
2837 }
2838 else
2839 {
2840 tempitem=getItemID(itemsbuf,itype_dinsfire,1);
2841
2842 if(tempitem<0) break;
2843
2844 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2845 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2846 {
2847 tempitemx=x;
2848 tempitemy=y;
2849 }
2850
2851 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2852 }
2853
2854 break;
2855
2856 case mfARROW:
2857 if(!hints)
2858 {
2859 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sARROW],tmpscr->secretcset[sARROW]);
2860 }
2861 else
2862 {
2863 tempitem=getItemID(itemsbuf,itype_arrow,1);
2864
2865 if(tempitem<0) break;
2866
2867 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2868 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2869 {
2870 tempitemx=x;
2871 tempitemy=y;
2872 }
2873
2874 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2875 }
2876
2877 break;
2878
2879 case mfSARROW:
2880 if(!hints)
2881 {
2882 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSARROW],tmpscr->secretcset[sSARROW]);
2883 }
2884 else
2885 {
2886 tempitem=getItemID(itemsbuf,itype_arrow,2);
2887
2888 if(tempitem<0) break;
2889
2890 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2891 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2892 {
2893 tempitemx=x;
2894 tempitemy=y;
2895 }
2896
2897 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2898 }
2899
2900 break;
2901
2902 case mfGARROW:
2903 if(!hints)
2904 {
2905 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sGARROW],tmpscr->secretcset[sGARROW]);
2906 }
2907 else
2908 {
2909 tempitem=getItemID(itemsbuf,itype_arrow,3);
2910
2911 if(tempitem<0) break;
2912
2913 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2914 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2915 {
2916 tempitemx=x;
2917 tempitemy=y;
2918 }
2919
2920 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2921 }
2922
2923 break;
2924
2925 case mfBOMB:
2926 if(!hints)
2927 {
2928 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBOMB],tmpscr->secretcset[sBOMB]);
2929 }
2930 else
2931 {
2932 //tempitem=getItemID(itemsbuf,itype_bomb,1);
2933 tempweapon = wLitBomb;
2934
2935 //if (tempitem<0) break;
2936 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2937 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2938 {
2939 tempweaponx=x;
2940 tempweapony=y;
2941 }
2942
2943 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2944 }
2945
2946 break;
2947
2948 case mfSBOMB:
2949 if(!hints)
2950 {
2951 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSBOMB],tmpscr->secretcset[sSBOMB]);
2952 }
2953 else
2954 {
2955 //tempitem=getItemID(itemsbuf,itype_sbomb,1);
2956 //if (tempitem<0) break;
2957 tempweapon = wLitSBomb;
2958
2959 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2960 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2961 {
2962 tempweaponx=x;
2963 tempweapony=y;
2964 }
2965
2966 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
2967 }
2968
2969 break;
2970
2971 case mfARMOS_SECRET:
2972 if(!hints)
2973 {
2974 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
2975 }
2976 break;
2977
2978 case mfBRANG:
2979 if(!hints)
2980 {
2981 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sBRANG],tmpscr->secretcset[sBRANG]);
2982 }
2983 else
2984 {
2985 tempitem=getItemID(itemsbuf,itype_brang,1);
2986
2987 if(tempitem<0) break;
2988
2989 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
2990 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
2991 {
2992 tempitemx=x;
2993 tempitemy=y;
2994 }
2995
2996 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
2997 }
2998
2999 break;
3000
3001 case mfMBRANG:
3002 if(!hints)
3003 {
3004 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMBRANG],tmpscr->secretcset[sMBRANG]);
3005 }
3006 else
3007 {
3008 tempitem=getItemID(itemsbuf,itype_brang,2);
3009
3010 if(tempitem<0) break;
3011
3012 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3013 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3014 {
3015 tempitemx=x;
3016 tempitemy=y;
3017 }
3018
3019 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3020 }
3021
3022 break;
3023
3024 case mfFBRANG:
3025 if(!hints)
3026 {
3027 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sFBRANG],tmpscr->secretcset[sFBRANG]);
3028 }
3029 else
3030 {
3031 tempitem=getItemID(itemsbuf,itype_brang,3);
3032
3033 if(tempitem<0) break;
3034
3035 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3036 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3037 {
3038 tempitemx=x;
3039 tempitemy=y;
3040 }
3041
3042 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3043 }
3044
3045 break;
3046
3047 case mfWANDMAGIC:
3048 if(!hints)
3049 {
3050 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWANDMAGIC],tmpscr->secretcset[sWANDMAGIC]);
3051 }
3052 else
3053 {
3054 tempitem=getItemID(itemsbuf,itype_wand,1);
3055
3056 if(tempitem<0) break;
3057
3058 tempweapon=itemsbuf[tempitem].wpn3;
3059
3060 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3061 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3062 {
3063 tempitemx=x;
3064 tempitemy=y;
3065 }
3066 else
3067 {
3068 tempweaponx=x;
3069 tempweapony=y;
3070 --lens_hint_weapon[wMagic][4];
3071
3072 if(lens_hint_weapon[wMagic][4]<-8)
3073 {
3074 lens_hint_weapon[wMagic][4]=8;
3075 }
3076 }
3077
3078 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3079 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3080 }
3081
3082 break;
3083
3084 case mfREFMAGIC:
3085 if(!hints)
3086 {
3087 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFMAGIC],tmpscr->secretcset[sREFMAGIC]);
3088 }
3089 else
3090 {
3091 tempitem=getItemID(itemsbuf,itype_shield,3);
3092
3093 if(tempitem<0) break;
3094
3095 tempweapon=ewMagic;
3096
3097 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3098 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3099 {
3100 tempitemx=x;
3101 tempitemy=y;
3102 }
3103 else
3104 {
3105 tempweaponx=x;
3106 tempweapony=y;
3107
3108 if(lens_hint_weapon[ewMagic][2]==up)
3109 {
3110 --lens_hint_weapon[ewMagic][4];
3111 }
3112 else
3113 {
3114 ++lens_hint_weapon[ewMagic][4];
3115 }
3116
3117 if(lens_hint_weapon[ewMagic][4]>8)
3118 {
3119 lens_hint_weapon[ewMagic][2]=up;
3120 }
3121
3122 if(lens_hint_weapon[ewMagic][4]<=0)
3123 {
3124 lens_hint_weapon[ewMagic][2]=down;
3125 }
3126 }
3127
3128 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3129 putweapon(dest,tempweaponx,tempweapony+lens_hint_weapon[tempweapon][4],tempweapon, 0, lens_hint_weapon[ewMagic][2], lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3130 }
3131
3132 break;
3133
3134 case mfREFFIREBALL:
3135 if(!hints)
3136 {
3137 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sREFFIREBALL],tmpscr->secretcset[sREFFIREBALL]);
3138 }
3139 else
3140 {
3141 tempitem=getItemID(itemsbuf,itype_shield,3);
3142
3143 if(tempitem<0) break;
3144
3145 tempweapon=ewFireball;
3146
3147 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3148 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3149 {
3150 tempitemx=x;
3151 tempitemy=y;
3152 tempweaponx=x;
3153 tempweapony=y;
3154 ++lens_hint_weapon[ewFireball][3];
3155
3156 if(lens_hint_weapon[ewFireball][3]>8)
3157 {
3158 lens_hint_weapon[ewFireball][3]=-8;
3159 lens_hint_weapon[ewFireball][4]=8;
3160 }
3161
3162 if(lens_hint_weapon[ewFireball][3]>0)
3163 {
3164 ++lens_hint_weapon[ewFireball][4];
3165 }
3166 else
3167 {
3168 --lens_hint_weapon[ewFireball][4];
3169 }
3170 }
3171
3172 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3173 putweapon(dest,tempweaponx+lens_hint_weapon[tempweapon][3],tempweapony+lens_hint_weapon[ewFireball][4],tempweapon, 0, up, lens_hint_weapon[tempweapon][0], lens_hint_weapon[tempweapon][1],-1);
3174 }
3175
3176 break;
3177
3178 case mfSWORD:
3179 if(!hints)
3180 {
3181 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORD],tmpscr->secretcset[sSWORD]);
3182 }
3183 else
3184 {
3185 tempitem=getItemID(itemsbuf,itype_sword,1);
3186
3187 if(tempitem<0) break;
3188
3189 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3190 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3191 {
3192 tempitemx=x;
3193 tempitemy=y;
3194 }
3195
3196 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3197 }
3198
3199 break;
3200
3201 case mfWSWORD:
3202 if(!hints)
3203 {
3204 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORD],tmpscr->secretcset[sWSWORD]);
3205 }
3206 else
3207 {
3208 tempitem=getItemID(itemsbuf,itype_sword,2);
3209
3210 if(tempitem<0) break;
3211
3212 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3213 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3214 {
3215 tempitemx=x;
3216 tempitemy=y;
3217 }
3218
3219 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3220 }
3221
3222 break;
3223
3224 case mfMSWORD:
3225 if(!hints)
3226 {
3227 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORD],tmpscr->secretcset[sMSWORD]);
3228 }
3229 else
3230 {
3231 tempitem=getItemID(itemsbuf,itype_sword,3);
3232
3233 if(tempitem<0) break;
3234
3235 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3236 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3237 {
3238 tempitemx=x;
3239 tempitemy=y;
3240 }
3241
3242 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3243 }
3244
3245 break;
3246
3247 case mfXSWORD:
3248 if(!hints)
3249 {
3250 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORD],tmpscr->secretcset[sXSWORD]);
3251 }
3252 else
3253 {
3254 tempitem=getItemID(itemsbuf,itype_sword,4);
3255
3256 if(tempitem<0) break;
3257
3258 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3259 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3260 {
3261 tempitemx=x;
3262 tempitemy=y;
3263 }
3264
3265 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3266 }
3267
3268 break;
3269
3270 case mfSWORDBEAM:
3271 if(!hints)
3272 {
3273 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sSWORDBEAM],tmpscr->secretcset[sSWORDBEAM]);
3274 }
3275 else
3276 {
3277 tempitem=getItemID(itemsbuf,itype_sword,1);
3278
3279 if(tempitem<0) break;
3280
3281 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3282 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3283 {
3284 tempitemx=x;
3285 tempitemy=y;
3286 }
3287
3288 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 1);
3289 }
3290
3291 break;
3292
3293 case mfWSWORDBEAM:
3294 if(!hints)
3295 {
3296 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWSWORDBEAM],tmpscr->secretcset[sWSWORDBEAM]);
3297 }
3298 else
3299 {
3300 tempitem=getItemID(itemsbuf,itype_sword,2);
3301
3302 if(tempitem<0) break;
3303
3304 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3305 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3306 {
3307 tempitemx=x;
3308 tempitemy=y;
3309 }
3310
3311 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 2);
3312 }
3313
3314 break;
3315
3316 case mfMSWORDBEAM:
3317 if(!hints)
3318 {
3319 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sMSWORDBEAM],tmpscr->secretcset[sMSWORDBEAM]);
3320 }
3321 else
3322 {
3323 tempitem=getItemID(itemsbuf,itype_sword,3);
3324
3325 if(tempitem<0) break;
3326
3327 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3328 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3329 {
3330 tempitemx=x;
3331 tempitemy=y;
3332 }
3333
3334 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 3);
3335 }
3336
3337 break;
3338
3339 case mfXSWORDBEAM:
3340 if(!hints)
3341 {
3342 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sXSWORDBEAM],tmpscr->secretcset[sXSWORDBEAM]);
3343 }
3344 else
3345 {
3346 tempitem=getItemID(itemsbuf,itype_sword,4);
3347
3348 if(tempitem<0) break;
3349
3350 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3351 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3352 {
3353 tempitemx=x;
3354 tempitemy=y;
3355 }
3356
3357 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 4);
3358 }
3359
3360 break;
3361
3362 case mfHOOKSHOT:
3363 if(!hints)
3364 {
3365 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHOOKSHOT],tmpscr->secretcset[sHOOKSHOT]);
3366 }
3367 else
3368 {
3369 tempitem=getItemID(itemsbuf,itype_hookshot,1);
3370
3371 if(tempitem<0) break;
3372
3373 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3374 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3375 {
3376 tempitemx=x;
3377 tempitemy=y;
3378 }
3379
3380 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3381 }
3382
3383 break;
3384
3385 case mfWAND:
3386 if(!hints)
3387 {
3388 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sWAND],tmpscr->secretcset[sWAND]);
3389 }
3390 else
3391 {
3392 tempitem=getItemID(itemsbuf,itype_wand,1);
3393
3394 if(tempitem<0) break;
3395
3396 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3397 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3398 {
3399 tempitemx=x;
3400 tempitemy=y;
3401 }
3402
3403 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3404 }
3405
3406 break;
3407
3408 case mfHAMMER:
3409 if(!hints)
3410 {
3411 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))putcombo(dest,x,y,tmpscr->secretcombo[sHAMMER],tmpscr->secretcset[sHAMMER]);
3412 }
3413 else
3414 {
3415 tempitem=getItemID(itemsbuf,itype_hammer,1);
3416
3417 if(tempitem<0) break;
3418
3419 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate))
3420 || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3421 {
3422 tempitemx=x;
3423 tempitemy=y;
3424 }
3425
3426 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3427 }
3428
3429 break;
3430
3431 case mfARMOS_ITEM:
3432 case mfDIVE_ITEM:
3433 if((!getmapflag() || (tmpscr->flags9&fBELOWRETURN)) && !(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG3))
3434 {
3435 putitem2(dest,x,y,tmpscr->catchall, lens_hint_item[tmpscr->catchall][0], lens_hint_item[tmpscr->catchall][1], 0);
3436 }
3437 break;
3438
3439 case 16:
3440 case 17:
3441 case 18:
3442 case 19:
3443 case 20:
3444 case 21:
3445 case 22:
3446 case 23:
3447 case 24:
3448 case 25:
3449 case 26:
3450 case 27:
3451 case 28:
3452 case 29:
3453 case 30:
3454 case 31:
3455 if(!hints)
3456 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3457 putcombo(dest,x,y,tmpscr->secretcombo[checkflag-16+4],tmpscr->secretcset[checkflag-16+4]);
3458
3459 break;
3460 case mfSECRETSNEXT:
3461 if(!hints)
3462 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3463 putcombo(dest,x,y,tmpscr->data[i]+1,tmpscr->cset[i]);
3464
3465 break;
3466
3467 case mfSTRIKE:
3468 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3469 {
3470 goto special;
3471 }
3472 else
3473 {
3474 break;
3475 }
3476
3477 default: goto special;
3478
3479 special:
3480 if(layer && ((checkflag!=mfRAFT && checkflag!=mfRAFT_BRANCH&& checkflag!=mfRAFT_BOUNCE) ||(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG4)))
3481 {
3482 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&blink_rate)) || ((get_debug() && zc_getkey(KEY_N)) && (frame&blink_rate)))
3483 {
3484 rectfill(dest,x,y,x+15,y+15,WHITE);
3485 }
3486 }
3487
3488 break;
3489 }
3490 }
3491 }
3492
3493 if(layer)
3494 {
3495 if(tmpscr->door[0]==dWALK)
3496 rectfill(dest, 120, 16+playing_field_offset, 135, 31+playing_field_offset, WHITE);
3497
3498 if(tmpscr->door[1]==dWALK)
3499 rectfill(dest, 120, 144+playing_field_offset, 135, 159+playing_field_offset, WHITE);
3500
3501 if(tmpscr->door[2]==dWALK)
3502 rectfill(dest, 16, 80+playing_field_offset, 31, 95+playing_field_offset, WHITE);
3503
3504 if(tmpscr->door[3]==dWALK)
3505 rectfill(dest, 224, 80+playing_field_offset, 239, 95+playing_field_offset, WHITE);
3506
3507 if(tmpscr->door[0]==dBOMB)
3508 {
3509 showbombeddoor(dest, 0);
3510 }
3511
3512 if(tmpscr->door[1]==dBOMB)
3513 {
3514 showbombeddoor(dest, 1);
3515 }
3516
3517 if(tmpscr->door[2]==dBOMB)
3518 {
3519 showbombeddoor(dest, 2);
3520 }
3521
3522 if(tmpscr->door[3]==dBOMB)
3523 {
3524 showbombeddoor(dest, 3);
3525 }
3526 }
3527
3528 if(tmpscr->stairx + tmpscr->stairy)
3529 {
3530 if(!hints)
3531 {
3532 if(!(itemsbuf[Hero.getLastLensID()].flags & ITEM_FLAG2))
3533 putcombo(dest,tmpscr->stairx,tmpscr->stairy+playing_field_offset,tmpscr->secretcombo[sSTAIRS],tmpscr->secretcset[sSTAIRS]);
3534 }
3535 else
3536 {
3537 if(tmpscr->flags&fWHISTLE)
3538 {
3539 tempitem=getItemID(itemsbuf,itype_whistle,1);
3540 int32_t tempitemx=-16;
3541 int32_t tempitemy=-16;
3542
3543 if((!(get_debug() && zc_getkey(KEY_N)) && (lensclk&(blink_rate/4)))
3544 || ((get_debug() && zc_getkey(KEY_N)) && (frame&(blink_rate/4))))
3545 {
3546 tempitemx=tmpscr->stairx;
3547 tempitemy=tmpscr->stairy+playing_field_offset;
3548 }
3549
3550 putitem2(dest,tempitemx,tempitemy,tempitem, lens_hint_item[tempitem][0], lens_hint_item[tempitem][1], 0);
3551 }
3552 }
3553 }
3554 }
3555 }
3556
3557 BITMAP *lens_scr_d; // The "d" is for "destructible"!
3558
3559 void draw_lens_over()
3560 {
3561 // Oh, what the heck.
3562 static BITMAP *lens_scr = NULL;
3563 static int32_t last_width = -1;
3564 int32_t width = itemsbuf[current_item_id(itype_lens,true)].misc1;
3565
3566 // Only redraw the circle if the size has changed
3567 if(width != last_width)
3568 {
3569 if(lens_scr == NULL)
3570 {
3571 lens_scr = create_bitmap_ex(8,2*288,2*(240-playing_field_offset));
3572 }
3573
3574 clear_to_color(lens_scr, BLACK);
3575 circlefill(lens_scr, 288, 240-playing_field_offset, width, 0);
3576 circle(lens_scr, 288, 240-playing_field_offset, width+2, 0);
3577 circle(lens_scr, 288, 240-playing_field_offset, width+5, 0);
3578 last_width=width;
3579 }
3580
3581 masked_blit(lens_scr, framebuf, 288-(HeroX()+8), 240-playing_field_offset-(HeroY()+8), 0, playing_field_offset, 256, 168);
3582 }
3583
3584 //----------------------------------------------------------------
3585
3586 void draw_wavy(BITMAP *source, BITMAP *target, int32_t amplitude, bool interpol)
3587 {
3588 //recreating a big bitmap every frame is highly sluggish.
3589 static BITMAP *wavebuf = create_bitmap_ex(8,288,240-original_playing_field_offset);
3590 clear_to_color(wavebuf, BLACK);
3591 blit(source,wavebuf,0,original_playing_field_offset,16,0,256,224-original_playing_field_offset);
3592
3593 int32_t ofs;
3594 // int32_t amplitude=8;
3595 // int32_t wavelength=4;
3596 amplitude = zc_min(2048,amplitude); // some arbitrary limit to prevent crashing
3597 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY)) amplitude = zc_min(16,amplitude);
3598 int32_t amp2=168;
3599 if((epilepsyFlashReduction || get_bit(quest_rules,qr_EPILEPSY)) && !get_bit(quest_rules, qr_WAVY_NO_EPILEPSY_2)) amp2*=2;
3600 int32_t i=frame%amp2;
3601
3602 for(int32_t j=0; j<168; j++)
3603 {
3604 if(j&1 && interpol)
3605 {
3606 // Add 288*2048 to ensure it's never negative. It'll get modded out.
3607 ofs=288*2048+int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3608 }
3609 else
3610 {
3611 ofs=288*2048-int32_t(zc::math::Sin((double(i+j)*2*PI/amp2))*amplitude);
3612 }
3613
3614 if(ofs)
3615 {
3616 for(int32_t k=0; k<256; k++)
3617 {
3618 target->line[j+original_playing_field_offset][k]=wavebuf->line[j][(k+ofs+16)%288];
3619 }
3620 }
3621 }
3622 }
3623
3624 void draw_fuzzy(int32_t fuzz)
3625 // draws from right half of scrollbuf to framebuf
3626 {
3627 int32_t firstx, firsty, xstep, ystep, i, y, dx, dy;
3628 byte *start, *si, *di;
3629
3630 if(fuzz<1)
3631 fuzz = 1;
3632
3633 xstep = 128%fuzz;
3634
3635 if(xstep > 0)
3636 xstep = fuzz-xstep;
3637
3638 ystep = 112%fuzz;
3639
3640 if(ystep > 0)
3641 ystep = fuzz-ystep;
3642
3643 firsty = 1;
3644
3645 for(y=0; y<224;)
3646 {
3647 start = &(scrollbuf->line[y][256]);
3648
3649 for(dy=0; dy<ystep && dy+y<224; dy++)
3650 {
3651 si = start;
3652 di = &(framebuf->line[y+dy][0]);
3653 i = xstep;
3654 firstx = 1;
3655
3656 for(dx=0; dx<256; dx++)
3657 {
3658 *(di++) = *si;
3659
3660 if(++i >= fuzz)
3661 {
3662 if(!firstx)
3663 si += fuzz;
3664 else
3665 {
3666 si += fuzz-xstep;
3667 firstx = 0;
3668 }
3669
3670 i = 0;
3671 }
3672 }
3673 }
3674
3675 if(!firsty)
3676 y += fuzz;
3677 else
3678 {
3679 y += ystep;
3680 ystep = fuzz;
3681 firsty = 0;
3682 }
3683 }
3684 }
3685
3686 203804 void updatescr(bool allowwavy)
3687 {
3688
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 203797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✓ Branch 4 taken 7 times.
✗ Branch 5 not taken.
203804 static BITMAP *wavybuf = create_bitmap_ex(8,256,224);
3689
4/6
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 203797 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 7 times.
203804 static BITMAP *panorama = create_bitmap_ex(8,256,224);
3690
3691
1/2
✓ Branch 0 taken 203804 times.
✗ Branch 1 not taken.
203804 if(toogam)
3692 {
3693 textout_ex(framebuf,font,"no walls",8,216,1,-1);
3694 }
3695
3696
1/2
✓ Branch 0 taken 203804 times.
✗ Branch 1 not taken.
203804 if(Showpal)
3697 dump_pal(framebuf);
3698
3699
2/2
✓ Branch 0 taken 201313 times.
✓ Branch 1 taken 2491 times.
203804 if(!Playing)
3700 2491 black_opening_count=0;
3701
3702
2/2
✓ Branch 0 taken 201824 times.
✓ Branch 1 taken 1980 times.
203804 if(black_opening_count<0) //shape is opening up
3703 {
3704 1980 black_opening(framebuf,black_opening_x,black_opening_y,(66+black_opening_count),66);
3705
3706
2/4
✓ Branch 0 taken 1980 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1980 times.
1980 if(Advance||(!Paused))
3707 {
3708 1980 ++black_opening_count;
3709 1980 }
3710 1980 }
3711
2/2
✓ Branch 0 taken 201296 times.
✓ Branch 1 taken 528 times.
201824 else if(black_opening_count>0) //shape is closing
3712 {
3713 528 black_opening(framebuf,black_opening_x,black_opening_y,black_opening_count,66);
3714
3715
2/4
✓ Branch 0 taken 528 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528 times.
528 if(Advance||(!Paused))
3716 {
3717 528 --black_opening_count;
3718 528 }
3719 528 }
3720
3721
3/4
✓ Branch 0 taken 201334 times.
✓ Branch 1 taken 2470 times.
✓ Branch 2 taken 201334 times.
✗ Branch 3 not taken.
203804 if(black_opening_count==0&&black_opening_shape==bosFADEBLACK)
3722 {
3723 black_opening_shape = bosCIRCLE;
3724 memcpy(RAMpal, tempblackpal, PAL_SIZE*sizeof(RGB));
3725 refreshTints();
3726 refreshpal=true;
3727 }
3728
3729
2/2
✓ Branch 0 taken 198835 times.
✓ Branch 1 taken 4969 times.
203804 if(refreshpal)
3730 {
3731 4969 refreshpal=false;
3732 4969 RAMpal[253] = _RGB(0,0,0);
3733 4969 RAMpal[254] = _RGB(63,63,63);
3734 4969 hw_palette = &RAMpal;
3735 4969 update_hw_pal = true;
3736
3737 4969 create_rgb_table(&rgb_table, RAMpal, NULL);
3738 4969 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3739 4969 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3740
3741
2/2
✓ Branch 0 taken 1272064 times.
✓ Branch 1 taken 4969 times.
1277033 for(int32_t q=0; q<PAL_SIZE; q++)
3742 {
3743 1272064 trans_table2.data[0][q] = q;
3744 1272064 trans_table2.data[q][q] = q;
3745 1272064 }
3746 4969 }
3747
3748 203804 bool clearwavy = (wavy <= 0);
3749
3750
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 if(wavy <= 0)
3751 {
3752 // So far one thing can alter wavy apart from scripts: Wavy DMaps.
3753 203804 wavy = (DMaps[currdmap].flags&dmfWAVY ? 4 : 0);
3754 203804 }
3755
3756 203804 blit(framebuf, wavybuf, 0, 0, 0, 0, 256, 224);
3757
3758
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
203804 if(wavy && Playing && allowwavy)
3759 {
3760 draw_wavy(framebuf, wavybuf, wavy,false);
3761 }
3762
3763
1/2
✓ Branch 0 taken 203804 times.
✗ Branch 1 not taken.
203804 if(clearwavy)
3764 203804 wavy = 0; // Wavy was set by a DMap flag. Clear it.
3765 else if(Playing && !Paused)
3766 wavy--; // Wavy was set by a script. Decrement it.
3767
3768
5/6
✓ Branch 0 taken 201313 times.
✓ Branch 1 taken 2491 times.
✓ Branch 2 taken 2339 times.
✓ Branch 3 taken 198974 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2339 times.
203804 if(Playing && msgpos && !screenscrolling)
3769 {
3770
1/2
✓ Branch 0 taken 2339 times.
✗ Branch 1 not taken.
2339 if(!(msg_bg_display_buf->clip))
3771 2339 blit_msgstr_bg(framebuf,0,0,0,playing_field_offset,256,168);
3772
1/2
✓ Branch 0 taken 2339 times.
✗ Branch 1 not taken.
2339 if(!(msg_portrait_display_buf->clip))
3773 2339 blit_msgstr_prt(framebuf,0,0,0,playing_field_offset,256,168);
3774
1/2
✓ Branch 0 taken 2339 times.
✗ Branch 1 not taken.
2339 if(!(msg_txt_display_buf->clip))
3775 2339 blit_msgstr_fg(framebuf,0,0,0,playing_field_offset,256,168);
3776 2339 }
3777
3778 /*
3779 if(!(msg_txt_display_buf->clip) && Playing && msgpos && !screenscrolling)
3780 {
3781 BITMAP* subBmp = 0;
3782 masked_blit(msg_txt_display_buf,subBmp,0,0,0,playing_field_offset,256,168);
3783 // masked_blit(msg_txt_display_buf,subBmp,0,playing_field_offset,256,168);
3784 draw_trans_sprite(framebuf, subBmp, 0, playing_field_offset);
3785 destroy_bitmap(subBmp);
3786 //void draw_sprite_ex(BITMAP *bmp, BITMAP *sprite, int32_t x, int32_t y, int32_t mode, int32_t flip);
3787 // masked_blit(msg_txt_display_buf,framebuf,0,0,0,playing_field_offset,256,168);
3788 //void masked_blit(BITMAP *source, BITMAP *dest, int32_t source_x, int32_t source_y, int32_t dest_x, int32_t dest_y, int32_t width, int32_t height);
3789 }
3790 */
3791
3792
1/2
✓ Branch 0 taken 203804 times.
✗ Branch 1 not taken.
203804 bool nosubscr = (tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET));
3793
3794
1/2
✓ Branch 0 taken 203804 times.
✗ Branch 1 not taken.
203804 if(nosubscr)
3795 {
3796 rectfill(panorama,0,0,255,passive_subscreen_height/2,0);
3797 rectfill(panorama,0,168+passive_subscreen_height/2,255,168+passive_subscreen_height-1,0);
3798 blit(wavybuf,panorama,0,playing_field_offset,0,passive_subscreen_height/2,256,224-passive_subscreen_height);
3799 }
3800
3801 //TODO: Optimize blit 'overcalls' -Gleeok
3802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 BITMAP *source = nosubscr ? panorama : wavybuf;
3803 203804 blit(source,framebuf,0,0,0,0,256,224);
3804
3805 203804 update_hw_screen();
3806 203804 }
3807
3808 //----------------------------------------------------------------
3809
3810 PALETTE sys_pal;
3811
3812 int32_t onGUISnapshot()
3813 {
3814 char buf[200];
3815 int32_t num=0;
3816 bool realpal=(key[KEY_ZC_LCONTROL] || key[KEY_ZC_RCONTROL]);
3817 do
3818 {
3819 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3820 }
3821 while(num<99999 && exists(buf));
3822
3823 BITMAP *b = create_bitmap_ex(8,resx,resy);
3824
3825 if(b)
3826 {
3827 if(MenuOpen)
3828 {
3829 //Cannot load game's palette while GUI elements are in focus. -Z
3830 //If there is a way to do this, then I have missed it.
3831 /*
3832 game_pal();
3833 RAMpal[253] = _RGB(0,0,0);
3834 RAMpal[254] = _RGB(63,63,63);
3835 set_palette_range(RAMpal,0,255,false);
3836 memcpy(RAMpal, snappal, sizeof(snappal));
3837 create_rgb_table(&rgb_table, RAMpal, NULL);
3838 create_zc_trans_table(&trans_table, RAMpal, 128, 128, 128);
3839 memcpy(&trans_table2, &trans_table, sizeof(COLOR_MAP));
3840
3841 for(int32_t q=0; q<PAL_SIZE; q++)
3842 {
3843 trans_table2.data[0][q] = q;
3844 trans_table2.data[q][q] = q;
3845 }
3846 */
3847 //ringcolor(false);
3848 //get_palette(RAMpal);
3849 blit(screen,b,0,0,0,0,resx,resy);
3850 //al_trace("Menu Open\n");
3851 //game_pal();
3852 //PALETTE temppal;
3853 //get_palette(temppal);
3854 //system_pal();
3855 save_bitmap(buf,b,sys_pal);
3856 //save_bitmap(buf,b,RAMpal);
3857 //save_bitmap(buf,b,snappal);
3858 }
3859 else
3860 {
3861 blit(screen,b,0,0,0,0,resx,resy);
3862 save_bitmap(buf,b,realpal?sys_pal:RAMpal);
3863 }
3864 destroy_bitmap(b);
3865 }
3866
3867 return D_O_K;
3868 }
3869
3870 int32_t onNonGUISnapshot()
3871 {
3872 PALETTE temppal;
3873 get_palette(temppal);
3874 bool realpal=(zc_getkey(KEY_ZC_LCONTROL, true) || zc_getkey(KEY_ZC_RCONTROL, true));
3875
3876 char buf[200];
3877 int32_t num=0;
3878
3879 do
3880 {
3881 sprintf(buf, "%szc_screen%05d.%s", get_snap_str(), ++num, snapshotformat_str[SnapshotFormat][1]);
3882 }
3883 while(num<99999 && exists(buf));
3884
3885 BITMAP *panorama = create_bitmap_ex(8,256,168);
3886 /*
3887 PALETTE tempRAMpal;
3888 get_palette(tempRAMpal);
3889
3890 if(tmpscr->flags3&fNOSUBSCR)
3891 {
3892 clear_to_color(panorama,0);
3893 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3894 save_bitmap(buf,panorama,realpal?temppal:tempRAMpal);
3895 }
3896 else
3897 {
3898 save_bitmap(buf,framebuf,realpal?temppal:tempRAMpal);
3899 }
3900
3901 destroy_bitmap(panorama);
3902 return D_O_K;
3903 */
3904 if(tmpscr->flags3&fNOSUBSCR && !(key[KEY_ALT]))
3905 {
3906 clear_to_color(panorama,0);
3907 blit(framebuf,panorama,0,playing_field_offset,0,0,256,168);
3908 save_bitmap(buf,panorama,realpal?temppal:RAMpal);
3909 }
3910 else
3911 {
3912 save_bitmap(buf,framebuf,realpal?temppal:RAMpal);
3913 }
3914
3915 destroy_bitmap(panorama);
3916 return D_O_K;
3917 }
3918
3919 int32_t onSnapshot()
3920 {
3921 if(zc_getkey(KEY_LSHIFT, true)||zc_getkey(KEY_RSHIFT, true))
3922 {
3923 onGUISnapshot();
3924 }
3925 else
3926 {
3927 onNonGUISnapshot();
3928 }
3929
3930 return D_O_K;
3931 }
3932
3933 int32_t onSaveMapPic()
3934 {
3935 int32_t mapres2 = 0;
3936 char buf[200];
3937 int32_t num=0;
3938 mapscr tmpscr_b[2];
3939 mapscr tmpscr_c[6];
3940 BITMAP* _screen_draw_buffer = NULL;
3941 _screen_draw_buffer = create_bitmap_ex(8,256,224);
3942 set_clip_state(_screen_draw_buffer,1);
3943
3944 for(int32_t i=0; i<6; ++i)
3945 {
3946 tmpscr_c[i] = tmpscr2[i];
3947 tmpscr2[i].zero_memory();
3948
3949 if(i>=2)
3950 {
3951 continue;
3952 }
3953
3954 tmpscr_b[i] = tmpscr[i];
3955 tmpscr[i].zero_memory();
3956 }
3957
3958 do
3959 {
3960 sprintf(buf, "%szc_screen%05d.png", get_snap_str(), ++num);
3961 }
3962 while(num<99999 && exists(buf));
3963
3964 BITMAP* mappic = NULL;
3965
3966
3967 bool done=false, redraw=true;
3968
3969 mappic = create_bitmap_ex(8,(256*16)>>mapres,(176*8)>>mapres);
3970
3971 if(!mappic)
3972 {
3973 system_pal();
3974 jwin_alert("View Map","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
3975 game_pal();
3976 return D_O_K;;
3977 }
3978
3979 // draw the map
3980 set_clip_rect(_screen_draw_buffer, 0, 0, _screen_draw_buffer->w, _screen_draw_buffer->h);
3981
3982 for(int32_t y=0; y<8; y++)
3983 {
3984 for(int32_t x=0; x<16; x++)
3985 {
3986 if(!displayOnMap(x, y))
3987 {
3988 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
3989 }
3990 else
3991 {
3992 int32_t s = (y<<4) + x;
3993 loadscr2(1,s,-1);
3994
3995 for(int32_t i=0; i<6; i++)
3996 {
3997 if(tmpscr[1].layermap[i]<=0)
3998 continue;
3999
4000 if((ZCMaps[tmpscr[1].layermap[i]-1].tileWidth==ZCMaps[currmap].tileWidth) &&
4001 (ZCMaps[tmpscr[1].layermap[i]-1].tileHeight==ZCMaps[currmap].tileHeight))
4002 {
4003 const int32_t _mapsSize = (ZCMaps[currmap].tileWidth)*(ZCMaps[currmap].tileHeight);
4004
4005 tmpscr2[i]=TheMaps[(tmpscr[1].layermap[i]-1)*MAPSCRS+tmpscr[1].layerscreen[i]];
4006 }
4007 }
4008
4009 if(XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4010
4011 if(XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4012
4013 putscr(_screen_draw_buffer,256,0,tmpscr+1);
4014 do_layer(_screen_draw_buffer, 0, 1, tmpscr+1, -256, playing_field_offset, 2);
4015
4016 if(!XOR((tmpscr+1)->flags7&fLAYER2BG, DMaps[currdmap].flags&dmfLAYER2BG)) do_layer(_screen_draw_buffer, 0, 2, tmpscr+1, -256, playing_field_offset, 2);
4017
4018 putscrdoors(_screen_draw_buffer,256,0,tmpscr+1);
4019 do_layer(_screen_draw_buffer, -2, 0, tmpscr+1, -256, playing_field_offset, 2);
4020 if(get_bit(quest_rules, qr_PUSHBLOCK_LAYER_1_2))
4021 {
4022 do_layer(_screen_draw_buffer, -2, 1, tmpscr+1, -256, playing_field_offset, 2);
4023 do_layer(_screen_draw_buffer, -2, 2, tmpscr+1, -256, playing_field_offset, 2);
4024 }
4025 do_layer(_screen_draw_buffer, -3, 0, tmpscr+1, -256, playing_field_offset, 2); // Freeform combos!
4026
4027 if(!XOR((tmpscr+1)->flags7&fLAYER3BG, DMaps[currdmap].flags&dmfLAYER3BG)) do_layer(_screen_draw_buffer, 0, 3, tmpscr+1, -256, playing_field_offset, 2);
4028
4029 do_layer(_screen_draw_buffer, 0, 4, tmpscr+1, -256, playing_field_offset, 2);
4030 do_layer(_screen_draw_buffer, -1, 0, tmpscr+1, -256, playing_field_offset, 2);
4031 if(get_bit(quest_rules, qr_OVERHEAD_COMBOS_L1_L2))
4032 {
4033 do_layer(_screen_draw_buffer, -1, 1, tmpscr+1, -256, playing_field_offset, 2);
4034 do_layer(_screen_draw_buffer, -1, 2, tmpscr+1, -256, playing_field_offset, 2);
4035 }
4036 do_layer(_screen_draw_buffer, 0, 5, tmpscr+1, -256, playing_field_offset, 2);
4037 do_layer(_screen_draw_buffer, 0, 6, tmpscr+1, -256, playing_field_offset, 2);
4038
4039 }
4040
4041 stretch_blit(_screen_draw_buffer, mappic, 256, 0, 256, 176, x<<(8-mapres), (y*176)>>mapres, 256>>mapres, 176>>mapres);
4042 }
4043 }
4044
4045 for(int32_t i=0; i<6; ++i)
4046 {
4047 tmpscr2[i]=tmpscr_c[i];
4048
4049 if(i>=2)
4050 {
4051 continue;
4052 }
4053
4054 tmpscr[i]=tmpscr_b[i];
4055 }
4056
4057 save_bitmap(buf,mappic,RAMpal);
4058 destroy_bitmap(mappic);
4059 destroy_bitmap(_screen_draw_buffer);
4060 return D_O_K;
4061 }
4062
4063 /*
4064 int32_t onSaveMapPic()
4065 {
4066 BITMAP* mappic = NULL;
4067 BITMAP* _screen_draw_buffer = NULL;
4068 _screen_draw_buffer = create_bitmap_ex(8,256,224);
4069 int32_t mapres2 = 0;
4070 char buf[20];
4071 int32_t num=0;
4072 set_clip_state(_screen_draw_buffer,1);
4073 set_clip_rect(_screen_draw_buffer,0,0,_screen_draw_buffer->w, _screen_draw_buffer->h);
4074
4075 do
4076 {
4077 sprintf(buf, "zelda%03d.png", ++num);
4078 }
4079 while(num<999 && exists(buf));
4080
4081 // if(!mappic) {
4082 mappic = create_bitmap_ex(8,(256*16)>>mapres2,(176*8)>>mapres2);
4083
4084 if(!mappic)
4085 {
4086 system_pal();
4087 jwin_alert("Save Map Picture","Not enough memory.",NULL,NULL,"OK",NULL,13,27,lfont);
4088 game_pal();
4089 return D_O_K;
4090 }
4091
4092 // }
4093
4094 int32_t layermap, layerscreen;
4095 int32_t x2=0;
4096
4097 // draw the map
4098 for(int32_t y=0; y<8; y++)
4099 {
4100 for(int32_t x=0; x<16; x++)
4101 {
4102 int32_t s = (y<<4) + x;
4103
4104 if(!displayOnMap(x, y))
4105 {
4106 rectfill(_screen_draw_buffer, 0, 0, 255, 223, WHITE);
4107 }
4108 else
4109 {
4110 loadscr(TEMPSCR_FUNCTION_SWAP_SPACE,currdmap,s,-1,false);
4111 putscr(_screen_draw_buffer, 0, 0, tmpscr+1);
4112
4113 for(int32_t k=0; k<4; k++)
4114 {
4115 if(k==2)
4116 {
4117 putscrdoors(_screen_draw_buffer, 0, 0, tmpscr+1);
4118 }
4119
4120 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4121
4122 if(layermap>-1)
4123 {
4124 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4125
4126 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4127 {
4128 for(int32_t i=0; i<176; i++)
4129 {
4130 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4131 }
4132 }
4133 else
4134 {
4135 for(int32_t i=0; i<176; i++)
4136 {
4137 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4138 }
4139 }
4140 }
4141 }
4142
4143 for(int32_t i=0; i<176; i++)
4144 {
4145 // if (COMBOTYPE((i&15)<<4,i&0xF0)==cOLD_OVERHEAD)
4146 if(combo_class_buf[COMBOTYPE((i&15)<<4,i&0xF0)].overhead)
4147 {
4148 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),MAPCOMBO((i&15)<<4,i&0xF0),MAPCSET((i&15)<<4,i&0xF0));
4149 }
4150 }
4151
4152 for(int32_t k=4; k<6; k++)
4153 {
4154 layermap=TheMaps[currmap*MAPSCRS+s].layermap[k]-1;
4155
4156 if(layermap>-1)
4157 {
4158 layerscreen=layermap*MAPSCRS+TheMaps[currmap*MAPSCRS+s].layerscreen[k];
4159
4160 if(TheMaps[currmap*MAPSCRS+s].layeropacity[k]==255)
4161 {
4162 for(int32_t i=0; i<176; i++)
4163 {
4164 overcombo(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i]);
4165 }
4166 }
4167 else
4168 {
4169 for(int32_t i=0; i<176; i++)
4170 {
4171 overcombotranslucent(_screen_draw_buffer,((i&15)<<4)+x2,(i&0xF0),TheMaps[layerscreen].data[i],TheMaps[layerscreen].cset[i],TheMaps[currmap*MAPSCRS+s].layeropacity[k]);
4172 }
4173 }
4174 }
4175 }
4176 }
4177
4178 stretch_blit(_screen_draw_buffer, mappic, 0, 0, 256, 176,
4179 x<<(8-mapres2), (y*176)>>mapres2, 256>>mapres2, 176>>mapres2);
4180 }
4181
4182 }
4183
4184 save_bitmap(buf,mappic,RAMpal);
4185 destroy_bitmap(mappic);
4186 destroy_bitmap(_screen_draw_buffer);
4187 return D_O_K;
4188 }
4189 */
4190
4191 1 void f_Quit(int32_t type)
4192 {
4193
2/4
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✗ Branch 3 not taken.
1 if(type==qQUIT && !Playing)
4194 return;
4195
4196 1 bool from_menu = is_sys_pal;
4197
4198
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4199 {
4200 1 music_pause();
4201 1 pause_all_sfx();
4202 1 }
4203 1 enter_sys_pal();
4204 1 clear_keybuf();
4205
4206 1 replay_poll();
4207
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (replay_is_replaying())
4208 1 replay_peek_quit();
4209
4210
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if (!replay_is_replaying())
4211 switch(type)
4212 {
4213 case qQUIT:
4214 onQuit();
4215 break;
4216
4217 case qRESET:
4218 onReset();
4219 break;
4220
4221 case qEXIT:
4222 onExit();
4223 break;
4224 }
4225
4226
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(Quit)
4227 {
4228 1 kill_sfx();
4229 1 music_stop();
4230 1 exit_sys_pal();
4231 1 update_hw_screen();
4232 1 }
4233 else
4234 {
4235 exit_sys_pal();
4236 if(!from_menu)
4237 {
4238 music_resume();
4239 resume_all_sfx();
4240 }
4241 }
4242
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(!from_menu)
4244 1 show_mouse(NULL);
4245 1 eat_buttons();
4246
4247 1 zc_readrawkey(KEY_ESC);
4248
4249 1 zc_readrawkey(KEY_ENTER);
4250 1 }
4251
4252 //----------------------------------------------------------------
4253
4254 int32_t onNoWalls()
4255 {
4256 cheats_enqueue(Cheat::Walls);
4257 return D_O_K;
4258 }
4259
4260 int32_t onIgnoreSideview()
4261 {
4262 cheats_enqueue(Cheat::IgnoreSideView);
4263 return D_O_K;
4264 }
4265
4266 208524 int32_t input_idle(bool checkmouse)
4267 {
4268 static int32_t mx, my, mz, mb;
4269
4270
4/6
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38297 times.
✓ Branch 3 taken 170227 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 38297 times.
246821 if(keypressed() || zc_key_pressed() ||
4271
4/8
✓ Branch 0 taken 38297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38297 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38297 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 38297 times.
✗ Branch 7 not taken.
38297 (checkmouse && (mx != mouse_x || my != mouse_y || mz != mouse_z || mb != mouse_b)))
4272 {
4273 170227 idle_count = 0;
4274
4275
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170227 times.
170227 if(active_count < MAX_ACTIVE)
4276 {
4277 170227 ++active_count;
4278 170227 }
4279 170227 }
4280
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 38297 times.
38297 else if(idle_count < MAX_IDLE)
4281 {
4282 38297 ++idle_count;
4283 38297 active_count = 0;
4284 38297 }
4285
4286 208524 mx = mouse_x;
4287 208524 my = mouse_y;
4288 208524 mz = mouse_z;
4289 208524 mb = mouse_b;
4290
4291 208524 return idle_count;
4292 }
4293
4294 int32_t onGoFast()
4295 {
4296 cheats_enqueue(Cheat::Fast);
4297 return D_O_K;
4298 }
4299
4300 int32_t onKillCheat()
4301 {
4302 cheats_enqueue(Cheat::Kill);
4303 return D_O_K;
4304 }
4305
4306 int32_t onShowLayer0()
4307 {
4308 show_layer_0 = !show_layer_0;
4309 return D_O_K;
4310 }
4311 int32_t onShowLayer1()
4312 {
4313 show_layer_1 = !show_layer_1;
4314 return D_O_K;
4315 }
4316 int32_t onShowLayer2()
4317 {
4318 show_layer_2 = !show_layer_2;
4319 return D_O_K;
4320 }
4321 int32_t onShowLayer3()
4322 {
4323 show_layer_3 = !show_layer_3;
4324 return D_O_K;
4325 }
4326 int32_t onShowLayer4()
4327 {
4328 show_layer_4 = !show_layer_4;
4329 return D_O_K;
4330 }
4331 int32_t onShowLayer5()
4332 {
4333 show_layer_5 = !show_layer_5;
4334 return D_O_K;
4335 }
4336 int32_t onShowLayer6()
4337 {
4338 show_layer_6 = !show_layer_6;
4339 return D_O_K;
4340 }
4341 int32_t onShowLayerO()
4342 {
4343 show_layer_over=!show_layer_over;
4344 return D_O_K;
4345 }
4346 int32_t onShowLayerP()
4347 {
4348 show_layer_push=!show_layer_push;
4349 return D_O_K;
4350 }
4351 int32_t onShowLayerS()
4352 {
4353 show_sprites=!show_sprites;
4354 return D_O_K;
4355 }
4356 int32_t onShowLayerF()
4357 {
4358 show_ffcs=!show_ffcs;
4359 return D_O_K;
4360 }
4361 int32_t onShowLayerW()
4362 {
4363 show_walkflags=!show_walkflags;
4364 return D_O_K;
4365 }
4366 int32_t onShowLayerE()
4367 {
4368 show_effectflags=!show_effectflags;
4369 return D_O_K;
4370 }
4371 int32_t onShowFFScripts()
4372 {
4373 show_ff_scripts=!show_ff_scripts;
4374 return D_O_K;
4375 }
4376 int32_t onShowHitboxes()
4377 {
4378 show_hitboxes=!show_hitboxes;
4379 return D_O_K;
4380 }
4381
4382 int32_t onLightSwitch()
4383 {
4384 cheats_enqueue(Cheat::Light);
4385 return D_O_K;
4386 }
4387
4388 int32_t onGoTo();
4389 int32_t onGoToComplete();
4390
4391 208524 void syskeys()
4392 {
4393 208524 update_system_keys();
4394
4395 int32_t oldtitle_version;
4396
4397
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(close_button_quit)
4398 {
4399 close_button_quit=false;
4400 f_Quit(qEXIT);
4401 }
4402
4403 208524 poll_joystick();
4404
4405
2/10
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 208524 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
208524 if(rMbtn() || (gui_mouse_b() && !mouse_down && ClickToFreeze &&!disableClickToFreeze))
4406 {
4407 oldtitle_version=title_version;
4408 System();
4409 }
4410
4411 208524 mouse_down=gui_mouse_b();
4412
4413
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(zc_read_system_key(KEY_F1))
4414 {
4415 if(zc_get_system_key(KEY_ZC_LCONTROL) || zc_get_system_key(KEY_ZC_RCONTROL))
4416 {
4417 halt=!halt;
4418 //zinit.subscreen=(zinit.subscreen+1)%ssdtMAX;
4419 }
4420 else
4421 {
4422 Throttlefps=!Throttlefps;
4423 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
4424 logic_counter=0;
4425 }
4426 }
4427
4428 // if(zc_readkey(KEY_F1)) Vsync=!Vsync;
4429 /*
4430 if(zc_readkey(KEY_F1)) set_bit(QHeader.rules4,qr4_NEWENEMYTILES,
4431 1-((get_bit(QHeader.rules4,qr4_NEWENEMYTILES))));
4432 */
4433
4434
1/4
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208524 if(zc_read_system_key(KEY_OPENBRACE)) if(frame_rest_suggest > 0) frame_rest_suggest--;
4435
4436
1/4
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208524 if(zc_read_system_key(KEY_CLOSEBRACE)) if(frame_rest_suggest <= 2) frame_rest_suggest++;
4437
4438
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(zc_read_system_key(KEY_F2))
4439 {
4440 ShowFPS=!ShowFPS;
4441 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
4442 }
4443
4444
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208524 if(zc_read_system_key(KEY_F3) && Playing) Paused=!Paused;
4445
4446
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208524 if(zc_read_system_key(KEY_F4) && Playing)
4447 {
4448 Paused=true;
4449 Advance=true;
4450 }
4451
4452
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(zc_read_system_key(KEY_F6)) onTryQuit();
4453
4454 #ifndef ALLEGRO_MACOSX
4455 if(zc_read_system_key(KEY_F9)) f_Quit(qRESET);
4456
4457 if(zc_read_system_key(KEY_F10)) f_Quit(qEXIT);
4458 #else
4459
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(zc_read_system_key(KEY_F7)) f_Quit(qRESET);
4460
4461
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(zc_read_system_key(KEY_F8)) f_Quit(qEXIT);
4462 #endif
4463
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
208524 if(zc_read_system_key(KEY_F5)&&(Playing && currscr<128 && DMaps[currdmap].flags&dmfVIEWMAP)) onSaveMapPic();
4464
4465
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if (zc_read_system_key(KEY_F12))
4466 {
4467 onSnapshot();
4468 }
4469
4470
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
208524 if(debug_enabled && zc_read_system_key(KEY_TAB))
4471 set_debug(!get_debug());
4472
4473
3/4
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11644 times.
✓ Branch 3 taken 196880 times.
208524 if(get_debug() || cheat>=1)
4474 {
4475
1/2
✓ Branch 0 taken 11644 times.
✗ Branch 1 not taken.
11644 if( CheatModifierKeys() )
4476 {
4477 if(zc_readkey(KEY_ASTERISK) || zc_readkey(KEY_H)) cheats_enqueue(Cheat::Life, game->get_maxlife());
4478
4479 if(zc_readkey(KEY_SLASH_PAD) || zc_readkey(KEY_M)) cheats_enqueue(Cheat::Magic, game->get_maxmagic());
4480
4481 if(zc_readkey(KEY_R)) cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
4482
4483 if(zc_readkey(KEY_B))
4484 {
4485 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
4486 }
4487
4488 if(zc_readkey(KEY_A))
4489 {
4490 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
4491 }
4492 }
4493 11644 }
4494
4495
3/4
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11644 times.
✓ Branch 3 taken 196880 times.
208524 if(get_debug() || cheat>=2)
4496 {
4497
1/2
✓ Branch 0 taken 11644 times.
✗ Branch 1 not taken.
11644 if( CheatModifierKeys() )
4498 {
4499 if(rI())
4500 {
4501 cheats_enqueue(Cheat::Clock);
4502 }
4503 }
4504 11644 }
4505
4506
3/4
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11644 times.
✓ Branch 3 taken 196880 times.
208524 if(get_debug() || cheat>=4)
4507 {
4508
1/2
✓ Branch 0 taken 11644 times.
✗ Branch 1 not taken.
11644 if( CheatModifierKeys() )
4509 {
4510 if(rF11())
4511 {
4512 cheats_enqueue(Cheat::Walls);
4513 }
4514
4515 if(rQ())
4516 {
4517 cheats_enqueue(Cheat::Fast);
4518 }
4519
4520 if(zc_readkey(KEY_F))
4521 {
4522 cheats_enqueue(Cheat::Freeze);
4523 }
4524
4525 if(zc_readkey(KEY_G)) onGoToComplete();
4526
4527 if(zc_readkey(KEY_0)) onShowLayer0();
4528
4529 if(zc_readkey(KEY_1)) onShowLayer1();
4530
4531 if(zc_readkey(KEY_2)) onShowLayer2();
4532
4533 if(zc_readkey(KEY_3)) onShowLayer3();
4534
4535 if(zc_readkey(KEY_4)) onShowLayer4();
4536
4537 if(zc_readkey(KEY_5)) onShowLayer5();
4538
4539 if(zc_readkey(KEY_6)) onShowLayer6();
4540
4541 //if(zc_readkey(KEY_7)) onShowLayerO();
4542 if(zc_readkey(KEY_7)) onShowLayerF();
4543
4544 if(zc_readkey(KEY_8)) onShowLayerS();
4545
4546 if(zc_readkey(KEY_W)) onShowLayerW();
4547
4548 if(zc_readkey(KEY_L)) cheats_enqueue(Cheat::Light);
4549
4550 if(zc_readkey(KEY_V)) cheats_enqueue(Cheat::IgnoreSideView);
4551
4552 if(zc_readkey(KEY_K)) cheats_enqueue(Cheat::Kill);
4553 if(zc_readkey(KEY_O)) onShowLayerO();
4554 if(zc_readkey(KEY_P)) onShowLayerP();
4555 if(zc_readkey(KEY_C)) onShowHitboxes();
4556 if(zc_readkey(KEY_F)) onShowFFScripts();
4557 }
4558 11644 }
4559
4560
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(volkeys)
4561 {
4562 if(zc_read_system_key(KEY_PGUP)) master_volume(-1,midi_volume+8);
4563
4564 if(zc_read_system_key(KEY_PGDN)) master_volume(-1,midi_volume==255?248:midi_volume-8);
4565
4566 if(zc_read_system_key(KEY_HOME)) master_volume(digi_volume+8,-1);
4567
4568 if(zc_read_system_key(KEY_END)) master_volume(digi_volume==255?248:digi_volume-8,-1);
4569 }
4570
4571
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
208524 if(!get_debug() || !SystemKeys || replay_is_replaying())
4572 208524 goto bottom;
4573
4574 if(zc_readkey(KEY_D))
4575 {
4576 details = !details;
4577 rectfill(screen,0,0,319,7,BLACK);
4578 rectfill(screen,0,8,31,239,BLACK);
4579 rectfill(screen,288,8,319,239,BLACK);
4580 rectfill(screen,32,232,287,239,BLACK);
4581 }
4582
4583 if(zc_readkey(KEY_P)) Paused=!Paused;
4584
4585 //if(zc_readkey(KEY_P)) centerHero();
4586 if(zc_readkey(KEY_A))
4587 {
4588 Paused=true;
4589 Advance=true;
4590 }
4591
4592 if(zc_readkey(KEY_G)) db=(db==999)?0:999;
4593 #ifndef ALLEGRO_MACOSX
4594 if(zc_readkey(KEY_F8)) Showpal=!Showpal;
4595
4596 if(zc_readkey(KEY_F7))
4597 {
4598 Matrix(ss_speed, ss_density, 0);
4599 game_pal();
4600 }
4601 #else
4602 // The reason these are different on Mac in the first place is that
4603 // the OS doesn't let us use F9 and F10...
4604 if(zc_readkey(KEY_F10)) Showpal=!Showpal;
4605
4606 if(zc_readkey(KEY_F9))
4607 {
4608 Matrix(ss_speed, ss_density, 0);
4609 game_pal();
4610 }
4611 #endif
4612 if(zc_readkey(KEY_PLUS_PAD) || zc_readkey(KEY_EQUALS))
4613 {
4614 //change containers
4615 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4616 {
4617 //magic containers
4618 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4619 {
4620 game->set_maxmagic(zc_min(game->get_maxmagic()+game->get_mp_per_block(),game->get_mp_per_block()*8));
4621 }
4622 else
4623 {
4624 game->set_maxlife(zc_min(game->get_maxlife()+game->get_hp_per_heart(),game->get_hp_per_heart()*24));
4625 }
4626 }
4627 else
4628 {
4629 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4630 {
4631 game->set_magic(zc_min(game->get_magic()+1,game->get_maxmagic()));
4632 }
4633 else
4634 {
4635 game->set_life(zc_min(game->get_life()+1,game->get_maxlife()));
4636 }
4637 }
4638 }
4639
4640 if(zc_readkey(KEY_MINUS_PAD) || zc_readkey(KEY_MINUS))
4641 {
4642 //change containers
4643 if(zc_getkey(KEY_ZC_LCONTROL) || zc_getkey(KEY_ZC_RCONTROL))
4644 {
4645 //magic containers
4646 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4647 {
4648 game->set_maxmagic(zc_max(game->get_maxmagic()-game->get_mp_per_block(),0));
4649 game->set_magic(zc_min(game->get_maxmagic(), game->get_magic()));
4650 //heart containers
4651 }
4652 else
4653 {
4654 game->set_maxlife(zc_max(game->get_maxlife()-game->get_hp_per_heart(),game->get_hp_per_heart()));
4655 game->set_life(zc_min(game->get_maxlife(), game->get_life()));
4656 }
4657 }
4658 else
4659 {
4660 if(zc_getkey(KEY_LSHIFT) || zc_getkey(KEY_RSHIFT))
4661 {
4662 game->set_magic(zc_max(game->get_magic()-1,0));
4663 }
4664 else
4665 {
4666 game->set_life(zc_max(game->get_life()-1,0));
4667 }
4668 }
4669 }
4670
4671 if(zc_readkey(KEY_COMMA)) jukebox(currmidi-1);
4672
4673 if(zc_readkey(KEY_STOP)) jukebox(currmidi+1);
4674
4675 verifyBothWeapons();
4676
4677 bottom:
4678
4679
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(input_idle(true) > after_time())
4680 {
4681 Matrix(ss_speed, ss_density, 0);
4682 game_pal();
4683 }
4684 //Saffith's method of separating system and game key bindings. Can't do this!!
4685 //restoreInput(); //This caused input to become randomly 'stuck'. -Z
4686
4687 //while(Playing && keypressed())
4688 //readkey();
4689 // What's the Playing check for?
4690 208524 clear_keybuf();
4691 208524 }
4692
4693 55900 void checkQuitKeys()
4694 {
4695 #ifndef ALLEGRO_MACOSX
4696 if(zc_readrawkey(KEY_F9)) f_Quit(qRESET);
4697
4698 if(zc_readrawkey(KEY_F10)) f_Quit(qEXIT);
4699 #else
4700
1/2
✓ Branch 0 taken 55900 times.
✗ Branch 1 not taken.
55900 if(zc_readrawkey(KEY_F7)) f_Quit(qRESET);
4701
4702
1/2
✓ Branch 0 taken 55900 times.
✗ Branch 1 not taken.
55900 if(zc_readrawkey(KEY_F8)) f_Quit(qEXIT);
4703 #endif
4704 55900 }
4705
4706 34932 bool CheatModifierKeys()
4707 {
4708 // Cheats are replayed via the X cheat step, no need to check for keyboard input
4709 // to trigger cheats.
4710
1/2
✓ Branch 0 taken 34932 times.
✗ Branch 1 not taken.
34932 if (replay_is_replaying())
4711 34932 return false;
4712
4713 if ( ( cheat_modifier_keys[0] > 0 && key[cheat_modifier_keys[0]] ) ||
4714 ( cheat_modifier_keys[1] > 0 && key[cheat_modifier_keys[1]] ) ||
4715 (cheat_modifier_keys[0] <= 0 && cheat_modifier_keys[1] <= 0))
4716 {
4717 if ( ( cheat_modifier_keys[2] <= 0 || key[cheat_modifier_keys[2]] ) ||
4718 ( cheat_modifier_keys[3] > 0 && key[cheat_modifier_keys[3]] ) ||
4719 (cheat_modifier_keys[2] <= 0 && cheat_modifier_keys[3] <= 0))
4720 {
4721 return true;
4722 }
4723 }
4724 return false;
4725 34932 }
4726
4727 //99:05:54, for some reason?
4728 #define OLDMAXTIME 21405240
4729 //9000:00:00, the highest even-thousand hour fitting within 32b signed. This is 375 *DAYS*.
4730 #define MAXTIME 1944000000
4731
4732 203807 void advanceframe(bool allowwavy, bool sfxcleanup, bool allowF6Script)
4733 {
4734
2/2
✓ Branch 0 taken 186444 times.
✓ Branch 1 taken 17363 times.
203807 if(zcmusic!=NULL)
4735 {
4736 17363 zcmusic_poll();
4737 17363 }
4738
4739
2/6
✗ Branch 0 not taken.
✓ Branch 1 taken 203807 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 203807 times.
203807 while(Paused && !Advance && !Quit)
4740 {
4741 // have to call this, otherwise we'll get an infinite loop
4742 syskeys();
4743 if(allowF6Script)
4744 {
4745 FFCore.runF6Engine();
4746 }
4747 if (replay_get_mode() != ReplayMode::Assert)
4748 updatescr(allowwavy);
4749 throttleFPS();
4750
4751 #ifdef _WIN32
4752
4753 if(use_dwm_flush)
4754 {
4755 do_DwmFlush();
4756 }
4757
4758 #endif
4759
4760 // to keep music playing
4761 if(zcmusic!=NULL)
4762 {
4763 zcmusic_poll();
4764 }
4765
4766 update_hw_screen();
4767 }
4768
4769
2/2
✓ Branch 0 taken 203804 times.
✓ Branch 1 taken 3 times.
203807 if(Quit)
4770 3 return;
4771
4772
3/4
✓ Branch 0 taken 201313 times.
✓ Branch 1 taken 2491 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 201313 times.
203804 if(Playing && game->get_time()<unsigned(get_bit(quest_rules,qr_GREATER_MAX_TIME) ? MAXTIME : OLDMAXTIME))
4773 201313 game->change_time(1);
4774
4775 203804 Advance=false;
4776
4777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 if (replay_is_active())
4778 {
4779
2/2
✓ Branch 0 taken 159096 times.
✓ Branch 1 taken 44708 times.
203804 if (replay_get_version() >= 3)
4780 44708 replay_poll();
4781
2/2
✓ Branch 0 taken 193051 times.
✓ Branch 1 taken 10753 times.
203804 if (replay_get_version() >= 6)
4782 10753 replay_peek_input();
4783 203804 }
4784 203804 update_keys();
4785
4786 203804 ++frame;
4787
4788
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 if (replay_is_replaying())
4789 203804 replay_do_cheats();
4790 203804 syskeys();
4791
4792 // Cheats used via the System menu (called by syskeys) will call cheats_enqueue. syskeys
4793 // is called just above, and in the paused loop above, so the queue-and-defer-slightly
4794 // approach here means it doesn't matter which call adds the cheat.
4795 203804 cheats_execute_queued();
4796
4797
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 if (replay_is_replaying())
4798 203804 replay_peek_quit();
4799
2/2
✓ Branch 0 taken 203803 times.
✓ Branch 1 taken 1 times.
203804 if (GameFlags & GAMEFLAG_TRYQUIT)
4800 1 replay_step_quit(0);
4801
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 if(allowF6Script)
4802 {
4803 203804 FFCore.runF6Engine();
4804 203804 }
4805
2/2
✓ Branch 0 taken 203789 times.
✓ Branch 1 taken 15 times.
203804 if (Quit)
4806 15 replay_step_quit(Quit);
4807 // Someday... maybe install a Turbo button here?
4808 203804 updatescr(allowwavy);
4809 203804 throttleFPS();
4810
4811 #ifdef _WIN32
4812
4813 if(use_dwm_flush)
4814 {
4815 do_DwmFlush();
4816 }
4817
4818 #endif
4819
4820 //textprintf_ex(screen,font,0,72,254,BLACK,"%d %d", lastentrance, lastentrance_dmap);
4821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203804 times.
203804 if(sfxcleanup)
4822 203804 sfx_cleanup();
4823 203807 }
4824
4825 void zapout()
4826 {
4827 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4828 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4829
4830 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4831 script_drawing_commands.Clear();
4832
4833 // zap out
4834 for(int32_t i=1; i<=24; i++)
4835 {
4836 draw_fuzzy(i);
4837 syskeys();
4838 advanceframe(true);
4839
4840 if(Quit)
4841 {
4842 break;
4843 }
4844 }
4845 }
4846
4847 void zapin()
4848 {
4849 FFCore.warpScriptCheck();
4850 draw_screen(tmpscr);
4851 set_clip_rect(scrollbuf, 0, 0, scrollbuf->w, scrollbuf->h);
4852 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4853 blit(framebuf,scrollbuf,0,0,256,0,256,224);
4854
4855 // zap out
4856 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4857 for(int32_t i=24; i>=1; i--)
4858 {
4859 draw_fuzzy(i);
4860 syskeys();
4861 advanceframe(true);
4862
4863 if(Quit)
4864 {
4865 break;
4866 }
4867 }
4868 }
4869
4870
4871 void wavyout(bool showhero)
4872 {
4873 draw_screen(tmpscr, showhero);
4874 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4875
4876 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4877 clear_to_color(wavebuf,0);
4878 blit(framebuf,wavebuf,0,0,16,0,256,224);
4879
4880 static PALETTE wavepal;
4881
4882 int32_t ofs;
4883 int32_t amplitude=8;
4884
4885 int32_t wavelength=4;
4886 double palpos=0, palstep=4, palstop=126;
4887
4888 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4889 for(int32_t i=0; i<168; i+=wavelength)
4890 {
4891 for(int32_t l=0; l<256; l++)
4892 {
4893 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4894 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4895 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4896 }
4897
4898 palpos+=palstep;
4899
4900 if(palpos>=0)
4901 {
4902 hw_palette = &wavepal;
4903 update_hw_pal = true;
4904 }
4905 else
4906 {
4907 hw_palette = &RAMpal;
4908 update_hw_pal = true;
4909 }
4910
4911 for(int32_t j=0; j+playing_field_offset<224; j++)
4912 {
4913 for(int32_t k=0; k<256; k++)
4914 {
4915 ofs=0;
4916
4917 if((j<i)&&(j&1))
4918 {
4919 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4920 }
4921
4922 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4923 }
4924 }
4925
4926 syskeys();
4927 advanceframe(true);
4928
4929 // animate_combos();
4930 if(Quit)
4931 break;
4932 }
4933
4934 destroy_bitmap(wavebuf);
4935 }
4936
4937 void wavyin()
4938 {
4939 draw_screen(tmpscr);
4940 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
4941
4942 BITMAP *wavebuf = create_bitmap_ex(8,288,224);
4943 clear_to_color(wavebuf,0);
4944 blit(framebuf,wavebuf,0,0,16,0,256,224);
4945
4946 static PALETTE wavepal;
4947
4948 //Breaks dark rooms.
4949 //In any case I don't think we need this, since palette is already loaded in doWarp() (famous last words...) -DD
4950 /*
4951 loadfullpal();
4952 loadlvlpal(DMaps[currdmap].color);
4953 ringcolor(false);
4954 */
4955 refreshpal=false;
4956 int32_t ofs;
4957 int32_t amplitude=8;
4958 int32_t wavelength=4;
4959 double palpos=168, palstep=4, palstop=126;
4960
4961 FFCore.runGenericPassiveEngine(SCR_TIMING_END_FRAME);
4962 for(int32_t i=0; i<168; i+=wavelength)
4963 {
4964 for(int32_t l=0; l<256; l++)
4965 {
4966 wavepal[l].r=vbound(int32_t(RAMpal[l].r+((palpos/palstop)*(63-RAMpal[l].r))),0,63);
4967 wavepal[l].g=vbound(int32_t(RAMpal[l].g+((palpos/palstop)*(63-RAMpal[l].g))),0,63);
4968 wavepal[l].b=vbound(int32_t(RAMpal[l].b+((palpos/palstop)*(63-RAMpal[l].b))),0,63);
4969 }
4970
4971 palpos-=palstep;
4972
4973 if(palpos>=0)
4974 {
4975 hw_palette = &wavepal;
4976 update_hw_pal = true;
4977 }
4978 else
4979 {
4980 hw_palette = &RAMpal;
4981 update_hw_pal = true;
4982 }
4983
4984 for(int32_t j=0; j+playing_field_offset<224; j++)
4985 {
4986 for(int32_t k=0; k<256; k++)
4987 {
4988 ofs=0;
4989
4990 if((j<(167-i))&&(j&1))
4991 {
4992 ofs=int32_t(zc::math::Sin((double(i+j)*2*PI/168.0))*amplitude);
4993 }
4994
4995 framebuf->line[j+playing_field_offset][k]=wavebuf->line[j+playing_field_offset][k+ofs+16];
4996 }
4997 }
4998
4999 syskeys();
5000 advanceframe(true);
5001 // animate_combos();
5002
5003 if(Quit)
5004 break;
5005 }
5006
5007 destroy_bitmap(wavebuf);
5008 }
5009
5010 81 void blackscr(int32_t fcnt,bool showsubscr)
5011 {
5012 81 reset_pal_cycling();
5013 81 script_drawing_commands.Clear();
5014
5015 81 FFCore.warpScriptCheck();
5016 81 bool showtime = game->should_show_time();
5017
2/2
✓ Branch 0 taken 81 times.
✓ Branch 1 taken 2430 times.
2511 while(fcnt>0)
5018 {
5019 2430 clear_bitmap(framebuf);
5020
5021
2/2
✓ Branch 0 taken 660 times.
✓ Branch 1 taken 1770 times.
2430 if(showsubscr)
5022 {
5023 1770 put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,showtime,sspUP);
5024
3/4
✓ Branch 0 taken 1770 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 1740 times.
1770 if(get_bit(quest_rules, qr_SCRIPTDRAWSINWARPS) || (get_bit(quest_rules, qr_PASSIVE_SUBSCRIPT_RUNS_WHEN_GAME_IS_FROZEN)))
5025 {
5026 30 do_script_draws(framebuf, tmpscr, 0, playing_field_offset);
5027 30 }
5028 1770 }
5029
5030 2430 syskeys();
5031 2430 advanceframe(true);
5032
5033
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2430 times.
2430 if(Quit)
5034 break;
5035
5036 2430 --fcnt;
5037 }
5038 81 }
5039
5040 33 void openscreen(int32_t shape)
5041 {
5042 33 reset_pal_cycling();
5043 33 black_opening_count=0;
5044
5045
3/4
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 25 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8 times.
33 if(COOLSCROLL || shape>-1)
5046 {
5047 25 open_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5048 25 return;
5049 }
5050 else
5051 {
5052 8 Hero.setDontDraw(true);
5053 8 show_subscreen_dmap_dots=false;
5054 8 show_subscreen_numbers=false;
5055 // show_subscreen_items=false;
5056 8 show_subscreen_life=false;
5057 }
5058
5059 8 int32_t x=128;
5060
5061 8 FFCore.warpScriptCheck();
5062
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 640 times.
648 for(int32_t i=0; i<80; i++)
5063 {
5064 640 draw_screen(tmpscr);
5065 //? draw_screen already draws the subscreen -DD
5066 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5067 640 x=128-(((i*128/80)/8)*8);
5068
5069
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 if(x>0)
5070 {
5071 640 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5072 640 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5073 640 }
5074
5075 // x=((80-i)/2)*4;
5076 /*
5077 --x;
5078 switch(++c)
5079 {
5080 case 5: c=0;
5081 case 0:
5082 case 2:
5083 case 3: --x; break;
5084 }
5085 */
5086 640 syskeys();
5087 640 advanceframe(true);
5088
5089
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 640 times.
640 if(Quit)
5090 {
5091 break;
5092 }
5093 640 }
5094
5095 8 Hero.setDontDraw(false);
5096 8 show_subscreen_items=true;
5097 8 show_subscreen_dmap_dots=true;
5098 33 }
5099
5100 void closescreen(int32_t shape)
5101 {
5102 reset_pal_cycling();
5103 black_opening_count=0;
5104
5105 if(COOLSCROLL || shape>-1)
5106 {
5107 close_black_opening(HeroX()+8, (HeroY()-HeroZ()-HeroFakeZ())+8+playing_field_offset, true, shape);
5108 return;
5109 }
5110 else
5111 {
5112 Hero.setDontDraw(true);
5113 show_subscreen_dmap_dots=false;
5114 show_subscreen_numbers=false;
5115 // show_subscreen_items=false;
5116 show_subscreen_life=false;
5117 }
5118
5119 int32_t x=128;
5120
5121 FFCore.warpScriptCheck();
5122 for(int32_t i=79; i>=0; --i)
5123 {
5124 draw_screen(tmpscr);
5125 //? draw_screen already draws the subscreen -DD
5126 //put_passive_subscr(framebuf,&QMisc,0,passive_subscreen_offset,false,sspUP);
5127 x=128-(((i*128/80)/8)*8);
5128
5129 if(x>0)
5130 {
5131 rectfill(framebuf,0,playing_field_offset,x,167+playing_field_offset,0);
5132 rectfill(framebuf,256-x,playing_field_offset,255,167+playing_field_offset,0);
5133 }
5134
5135 // x=((80-i)/2)*4;
5136 /*
5137 --x;
5138 switch(++c)
5139 {
5140 case 5: c=0;
5141 case 0:
5142 case 2:
5143 case 3: --x; break;
5144 }
5145 */
5146 syskeys();
5147 advanceframe(true);
5148
5149 if(Quit)
5150 {
5151 break;
5152 }
5153 }
5154
5155 Hero.setDontDraw(false);
5156 show_subscreen_items=true;
5157 show_subscreen_dmap_dots=true;
5158 }
5159
5160 int32_t TriforceCount()
5161 {
5162 int32_t c=0;
5163
5164 for(int32_t i=1; i<=8; i++)
5165 if(game->lvlitems[i]&liTRIFORCE)
5166 ++c;
5167
5168 return c;
5169 }
5170
5171 int32_t onCustomGame()
5172 {
5173 int32_t file = getsaveslot();
5174
5175 if(file < 0)
5176 return D_O_K;
5177
5178 bool ret = (custom_game(file)!=0);
5179 return ret ? D_CLOSE : D_O_K;
5180 }
5181
5182 int32_t onContinue()
5183 {
5184 return D_CLOSE;
5185 }
5186
5187 int32_t onEsc() // Unused?? -L
5188 {
5189 return zc_getrawkey(KEY_ESC, true)?D_CLOSE:D_O_K;
5190 }
5191
5192 int32_t onVsync()
5193 {
5194 Throttlefps = !Throttlefps;
5195 zc_set_config(cfg_sect,"throttlefps", (int32_t)Throttlefps);
5196 return D_O_K;
5197 }
5198
5199 int32_t onWinPosSave()
5200 {
5201 SaveWinPos = !SaveWinPos;
5202 zc_set_config(cfg_sect,"save_window_position",(int32_t)SaveWinPos);
5203 return D_O_K;
5204 }
5205
5206 int32_t onClickToFreeze()
5207 {
5208 ClickToFreeze = !ClickToFreeze;
5209 zc_set_config(cfg_sect,"clicktofreeze", (int32_t)ClickToFreeze);
5210 return D_O_K;
5211 }
5212
5213 int32_t OnSaveZCConfig()
5214 {
5215 if(jwin_alert3(
5216 "Save Configuration",
5217 "Are you sure that you wish to save your present configuration settings?",
5218 "This will overwrite your prior settings!",
5219 NULL,
5220 "&Yes",
5221 "&No",
5222 NULL,
5223 'y',
5224 'n',
5225 0,
5226 lfont) == 1)
5227 {
5228 save_game_configs();
5229 return D_O_K;
5230 }
5231 else return D_O_K;
5232 }
5233
5234 int32_t OnnClearQuestDir()
5235 {
5236 if(jwin_alert3(
5237 "Clear Current Directory Cache",
5238 "Are you sure that you wish to clear the current cached directory?",
5239 "This will default the current directory to the ROOT for this instance of ZC Player!",
5240 NULL,
5241 "&Yes",
5242 "&No",
5243 NULL,
5244 'y',
5245 'n',
5246 0,
5247 lfont) == 1)
5248 {
5249 zc_set_config("zeldadx","win_qst_dir","");
5250 flush_config_file();
5251 strcpy(qstdir,"");
5252 #ifdef __EMSCRIPTEN__
5253 em_sync_fs();
5254 #endif
5255 return D_O_K;
5256 }
5257 else return D_O_K;
5258 }
5259
5260
5261 int32_t onConsoleZASM()
5262 {
5263 if ( !zasm_debugger )
5264 {
5265 AlertDialog("WARNING: ZASM Debugger",
5266 "Enabling this will open the ZASM Debugger Console"
5267 "\nThis will likely grind ZC to a halt with lag."
5268 "\nTo make any use of this, it is suggested that you read"
5269 "\nthe documentation for 'void Breakpoint(char[] string);'"
5270 " in 'ZScript_Additions.txt'"
5271 "\nThis is not recommended for normal users,"
5272 " and is only intended for ZC developers,"
5273 "\nor quest developers coding directly in ZASM"
5274 "\nAre you sure that you wish to open the ZASM Debugger?",
5275 [&](bool ret,bool)
5276 {
5277 if(ret)
5278 {
5279 FFCore.ZASMPrint(true);
5280 }
5281 }).show();
5282 return D_O_K;
5283 }
5284 else
5285 {
5286 FFCore.ZASMPrint(false);
5287 return D_O_K;
5288 }
5289 }
5290
5291
5292 int32_t onConsoleZScript()
5293 {
5294 if ( !zscript_debugger )
5295 {
5296 AlertDialog("ZScript Debugger",
5297 "Enabling this will open the ZScript Debugger Console"
5298 "\nThis will display any messages logged by scripts,"
5299 " including script errors."
5300 "\nAre you sure that you wish to open the ZScript Debugger?",
5301 [&](bool ret,bool)
5302 {
5303 if(ret)
5304 {
5305 FFCore.ZScriptConsole(true);
5306 }
5307 }).show();
5308 return D_O_K;
5309 }
5310 else
5311 {
5312 FFCore.ZScriptConsole(false);
5313 return D_O_K;
5314 }
5315 }
5316
5317
5318 int32_t onFrameSkip()
5319 {
5320 FrameSkip = !FrameSkip;
5321 return D_O_K;
5322 }
5323
5324 int32_t onSaveDragResize()
5325 {
5326 SaveDragResize = !SaveDragResize;
5327 zc_set_config(cfg_sect,"save_drag_resize",(int32_t)SaveDragResize);
5328 return D_O_K;
5329 }
5330
5331 int32_t onDragAspect()
5332 {
5333 DragAspect = !DragAspect;
5334 zc_set_config(cfg_sect,"drag_aspect",(int32_t)DragAspect);
5335 return D_O_K;
5336 }
5337
5338 int32_t onTransLayers()
5339 {
5340 TransLayers = !TransLayers;
5341 zc_set_config(cfg_sect,"translayers",(int32_t)TransLayers);
5342 return D_O_K;
5343 }
5344
5345 int32_t onNESquit()
5346 {
5347 NESquit = !NESquit;
5348 zc_set_config(cfg_sect,"fastquit",(int32_t)NESquit);
5349 return D_O_K;
5350 }
5351
5352 int32_t onVolKeys()
5353 {
5354 volkeys = !volkeys;
5355 zc_set_config(sfx_sect,"volkeys",(int32_t)volkeys);
5356 return D_O_K;
5357 }
5358
5359 int32_t onShowFPS()
5360 {
5361 ShowFPS = !ShowFPS;
5362 zc_set_config(cfg_sect,"showfps",(int32_t)ShowFPS);
5363 return D_O_K;
5364 }
5365
5366 24605832 bool is_Fkey(int32_t k)
5367 {
5368
2/2
✓ Branch 0 taken 2502288 times.
✓ Branch 1 taken 22103544 times.
24605832 switch(k)
5369 {
5370 case KEY_F1:
5371 case KEY_F2:
5372 case KEY_F3:
5373 case KEY_F4:
5374 case KEY_F5:
5375 case KEY_F6:
5376 case KEY_F7:
5377 case KEY_F8:
5378 case KEY_F9:
5379 case KEY_F10:
5380 case KEY_F11:
5381 case KEY_F12:
5382 2502288 return true;
5383 }
5384
5385 22103544 return false;
5386 24605832 }
5387
5388 void kb_getkey(DIALOG *d)
5389 {
5390 d->flags|=D_SELECTED;
5391
5392 scare_mouse();
5393 jwin_button_proc(MSG_DRAW,d,0);
5394 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5395 // text_mode(vc(11));
5396 textout_centre_ex(gui_bmp, font, "Press a key", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5397 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5398 unscare_mouse();
5399
5400 update_hw_screen(true);
5401
5402 clear_keybuf();
5403 int32_t k = next_press_key();
5404 clear_keybuf();
5405
5406 //shnarf
5407 //47=f1
5408 //59=esc
5409 if(k>0 && k<123 && !((k>46)&&(k<60)))
5410 *((int32_t*)d->dp3) = k;
5411
5412
5413 d->flags&=~D_SELECTED;
5414 }
5415
5416
5417 //Used by all keyboard key settings dialogues.
5418 void kb_clearjoystick(DIALOG *d)
5419 {
5420 d->flags|=D_SELECTED;
5421
5422 scare_mouse();
5423 jwin_button_proc(MSG_DRAW,d,0);
5424 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 168, 48, FR_WIN);
5425 // text_mode(vc(11));
5426 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5427 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5428 unscare_mouse();
5429
5430 update_hw_screen(true);
5431
5432 clear_keybuf();
5433 int32_t k = next_press_key();
5434 clear_keybuf();
5435
5436 //shnarf
5437 //47=f1
5438 //59=esc
5439 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5440 // *((int32_t*)d->dp3) = k;
5441 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5442
5443
5444 d->flags&=~D_SELECTED;
5445 }
5446
5447 //Clears key to 0.
5448 //Used by all keyboard key settings dialogues.
5449 void kb_clearkey(DIALOG *d)
5450 {
5451 d->flags|=D_SELECTED;
5452
5453 scare_mouse();
5454 jwin_button_proc(MSG_DRAW,d,0);
5455 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5456 // text_mode(vc(11));
5457 textout_centre_ex(gui_bmp, font, "Press any key to clear", gui_bmp->w/2, gui_bmp->h/2 - 8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5458 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, gui_bmp->h/2, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5459 unscare_mouse();
5460
5461 update_hw_screen(true);
5462
5463 clear_keybuf();
5464 int32_t k = next_press_key();
5465 clear_keybuf();
5466
5467 //shnarf
5468 //47=f1
5469 //59=esc
5470 // if(k>0 && k<123 && !((k>46)&&(k<60)))
5471 // *((int32_t*)d->dp3) = k;
5472 if ( k != 59 ) *((int32_t*)d->dp3) = 0;
5473
5474
5475 d->flags&=~D_SELECTED;
5476 }
5477
5478
5479 int32_t d_j_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5480 {
5481 switch(msg)
5482 {
5483 case MSG_KEY:
5484 case MSG_CLICK:
5485
5486 kb_clearjoystick(d);
5487
5488 while(gui_mouse_b())
5489 {
5490 clear_keybuf();
5491 rest(1);
5492 }
5493
5494 return D_REDRAW;
5495 }
5496
5497 return jwin_button_proc(msg,d,c);
5498 }
5499
5500 int32_t d_kbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5501 {
5502 switch(msg)
5503 {
5504 case MSG_KEY:
5505 case MSG_CLICK:
5506
5507 kb_getkey(d);
5508
5509 while(gui_mouse_b()) {
5510 clear_keybuf();
5511 rest(1);
5512 }
5513
5514 return D_REDRAW;
5515 }
5516
5517 return jwin_button_proc(msg,d,c);
5518 }
5519
5520 //Only used in keyboard settings dialogues to clear keys.
5521 int32_t d_k_clearbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5522 {
5523 switch(msg)
5524 {
5525 case MSG_KEY:
5526 case MSG_CLICK:
5527
5528 kb_clearkey(d);
5529
5530 while(gui_mouse_b()) {
5531 clear_keybuf();
5532 rest(1);
5533 }
5534
5535 return D_REDRAW;
5536 }
5537
5538 return jwin_button_proc(msg,d,c);
5539 }
5540
5541 void j_getbtn(DIALOG *d)
5542 {
5543 d->flags|=D_SELECTED;
5544 scare_mouse();
5545 jwin_button_proc(MSG_DRAW,d,0);
5546 jwin_draw_win(gui_bmp, (gui_bmp->w-160)/2, (gui_bmp->h-48)/2, 160, 48, FR_WIN);
5547 // text_mode(vc(11));
5548 int32_t y = gui_bmp->h/2 - 12;
5549 textout_centre_ex(gui_bmp, font, "Press a button", gui_bmp->w/2, y, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5550 textout_centre_ex(gui_bmp, font, "ESC to cancel", gui_bmp->w/2, y+8, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5551 textout_centre_ex(gui_bmp, font, "SPACE to disable", gui_bmp->w/2, y+16, jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5552 unscare_mouse();
5553
5554 update_hw_screen(true);
5555
5556 int32_t b = next_press_btn();
5557
5558 if(b>=0)
5559 *((int32_t*)d->dp3) = b;
5560
5561 d->flags&=~D_SELECTED;
5562
5563 if (player)
5564 player->joy_on = TRUE;
5565 }
5566
5567 int32_t d_jbutton_proc(int32_t msg,DIALOG *d,int32_t c)
5568 {
5569 switch(msg)
5570 {
5571 case MSG_KEY:
5572 case MSG_CLICK:
5573
5574 j_getbtn(d);
5575
5576 while(gui_mouse_b()) {
5577 rest(1);
5578 clear_keybuf();
5579 }
5580
5581 return D_REDRAW;
5582 }
5583
5584 return jwin_button_proc(msg,d,c);
5585 }
5586
5587 //shnarf
5588 const char *key_str[] =
5589 {
5590 "(none) ", "a ", "b ", "c ",
5591 "d ", "e ", "f ", "g ",
5592 "h ", "i ", "j ", "k ",
5593 "l ", "m ", "n ", "o ",
5594 "p ", "q ", "r ", "s ",
5595 "t ", "u ", "v ", "w ",
5596 "x ", "y ", "z ", "0 ",
5597 "1 ", "2 ", "3 ", "4 ",
5598 "5 ", "6 ", "7 ", "8 ",
5599 "9 ", "num 0 ", "num 1 ", "num 2 ",
5600 "num 3 ", "num 4 ", "num 5 ", "num 6 ",
5601 "num 7 ", "num 8 ", "num 9 ", "f1 ",
5602 "f2 ", "f3 ", "f4 ", "f5 ",
5603 "f6 ", "f7 ", "f8 ", "f9 ",
5604 "f10 ", "f11 ", "f12 ", "esc ",
5605 "~ ", "- ", "= ", "backspace ",
5606 "tab ", "{ ", "} ", "enter ",
5607 ": ", "quote ", "\\ ", "\\ (2) ",
5608 ", ", ". ", "/ ", "space ",
5609 "insert ", "delete ", "home ", "end ",
5610 "page up ", "page down ", "left ", "right ",
5611 "up ", "down ", "num / ", "num * ",
5612 "num - ", "num + ", "num delete ", "num enter ",
5613 "print screen ", "pause ", "abnt c1 ", "yen ",
5614 "kana ", "convert ", "no convert ", "at ",
5615 "circumflex ", ": (2) ", "kanji ", "num = ",
5616 "back quote ", "; ", "command ", "unknown (0) ",
5617 "unknown (1) ", "unknown (2) ", "unknown (3) ", "unknown (4) ",
5618 "unknown (5) ", "unknown (6) ", "unknown (7) ", "left shift ",
5619 "right shift ", "left control ", "right control", "alt ",
5620 "alt gr ", "left win ", "right win ", "menu ",
5621 "scroll lock ", "number lock ", "caps lock ", "MAX"
5622 };
5623
5624
5625 const char *pan_str[4] = { "MONO", " 1/2", " 3/4", "FULL" };
5626 //extern int32_t zcmusic_bufsz;
5627
5628 static char str_a[80],str_b[80],str_s[80],str_m[80],str_l[80],str_r[80],str_p[80],str_ex1[80],str_ex2[80],str_ex3[80],str_ex4[80],
5629 str_leftmod1[80],str_leftmod2[80],str_rightmod1[80],str_rightmod2[80], str_left[80], str_right[80], str_up[80], str_down[80];
5630
5631 int32_t d_stringloader(int32_t msg,DIALOG *d,int32_t c)
5632 {
5633 //these are here to bypass compiler warnings about unused arguments
5634 c=c;
5635
5636 if(msg==MSG_DRAW)
5637 {
5638 switch(d->w)
5639 {
5640 case 0:
5641 sprintf(str_a,"%03d\n%s",Akey,key_str[Akey]);
5642 sprintf(str_b,"%03d\n%s",Bkey,key_str[Bkey]);
5643 sprintf(str_s,"%03d\n%s",Skey,key_str[Skey]);
5644 sprintf(str_l,"%03d\n%s",Lkey,key_str[Lkey]);
5645 sprintf(str_r,"%03d\n%s",Rkey,key_str[Rkey]);
5646 sprintf(str_p,"%03d\n%s",Pkey,key_str[Pkey]);
5647 sprintf(str_ex1,"%03d\n%s",Exkey1,key_str[Exkey1]);
5648 sprintf(str_ex2,"%03d\n%s",Exkey2,key_str[Exkey2]);
5649 sprintf(str_ex3,"%03d\n%s",Exkey3,key_str[Exkey3]);
5650 sprintf(str_ex4,"%03d\n%s",Exkey4,key_str[Exkey4]);
5651 sprintf(str_up,"%03d\n%s",DUkey,key_str[DUkey]);
5652 sprintf(str_down,"%03d\n%s",DDkey,key_str[DDkey]);
5653 sprintf(str_left,"%03d\n%s",DLkey,key_str[DLkey]);
5654 sprintf(str_right,"%03d\n%s",DRkey,key_str[DRkey]);
5655 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5656 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5657 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5658 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5659 break;
5660
5661 case 1:
5662 sprintf(str_a,"%03d\n%s",Abtn,joybtn_name(Abtn));
5663 sprintf(str_b,"%03d\n%s",Bbtn,joybtn_name(Bbtn));
5664 sprintf(str_s,"%03d\n%s",Sbtn,joybtn_name(Sbtn));
5665 sprintf(str_l,"%03d\n%s",Lbtn,joybtn_name(Lbtn));
5666 sprintf(str_r,"%03d\n%s",Rbtn,joybtn_name(Rbtn));
5667 sprintf(str_m,"%03d\n%s",Mbtn,joybtn_name(Mbtn));
5668 sprintf(str_p,"%03d\n%s",Pbtn,joybtn_name(Pbtn));
5669 sprintf(str_ex1,"%03d\n%s",Exbtn1,joybtn_name(Exbtn1));
5670 sprintf(str_ex2,"%03d\n%s",Exbtn2,joybtn_name(Exbtn2));
5671 sprintf(str_ex3,"%03d\n%s",Exbtn3,joybtn_name(Exbtn3));
5672 sprintf(str_ex4,"%03d\n%s",Exbtn4,joybtn_name(Exbtn4));
5673 sprintf(str_up,"%03d\n%s",DUbtn,joybtn_name(DUbtn));
5674 sprintf(str_down,"%03d\n%s",DDbtn,joybtn_name(DDbtn));
5675 sprintf(str_left,"%03d\n%s",DLbtn,joybtn_name(DLbtn));
5676 sprintf(str_right,"%03d\n%s",DRbtn,joybtn_name(DRbtn));
5677 sprintf(str_leftmod1,"%03d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5678 sprintf(str_leftmod2,"%03d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5679 sprintf(str_rightmod1,"%03d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5680 sprintf(str_rightmod2,"%03d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5681 break;
5682
5683 case 2:
5684 sprintf(str_a," %3d",midi_volume);
5685 sprintf(str_b," %3d",digi_volume);
5686 sprintf(str_l," %3d",emusic_volume);
5687 sprintf(str_m," %3dKB",zcmusic_bufsz);
5688 sprintf(str_r," %3d",sfx_volume);
5689 strcpy(str_s,pan_str[pan_style]);
5690 sprintf(str_leftmod1,"%3d\n%s",cheat_modifier_keys[0],key_str[cheat_modifier_keys[0]]);
5691 sprintf(str_leftmod2,"%3d\n%s",cheat_modifier_keys[1],key_str[cheat_modifier_keys[1]]);
5692 sprintf(str_rightmod1,"%3d\n%s",cheat_modifier_keys[2],key_str[cheat_modifier_keys[2]]);
5693 sprintf(str_rightmod2,"%3d\n%s",cheat_modifier_keys[3],key_str[cheat_modifier_keys[3]]);
5694 break;
5695 }
5696 }
5697
5698 return D_O_K;
5699 }
5700
5701 int32_t set_vol(void *dp3, int32_t d2)
5702 {
5703 switch(((int32_t*)dp3)[0])
5704 {
5705 case 0:
5706 midi_volume = zc_min(d2<<3,255);
5707 break;
5708
5709 case 1:
5710 digi_volume = zc_min(d2<<3,255);
5711 break;
5712
5713 case 2:
5714 emusic_volume = zc_min(d2<<3,255);
5715 break;
5716
5717 case 3:
5718 sfx_volume = zc_min(d2<<3,255);
5719 break;
5720 }
5721
5722 scare_mouse();
5723 // text_mode(vc(11));
5724 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3d",zc_min(d2<<3,255));
5725 unscare_mouse();
5726 return D_O_K;
5727 }
5728
5729 int32_t set_pan(void *dp3, int32_t d2)
5730 {
5731 pan_style = vbound(d2,0,3);
5732 scare_mouse();
5733 // text_mode(vc(11));
5734 textout_right_ex(screen,is_large ? lfont_l : font, pan_str[pan_style],((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX]);
5735 unscare_mouse();
5736 return D_O_K;
5737 }
5738
5739 int32_t set_buf(void *dp3, int32_t d2)
5740 {
5741 scare_mouse();
5742 // text_mode(vc(11));
5743 zcmusic_bufsz = d2 + 1;
5744 textprintf_right_ex(screen,is_large ? lfont_l : font, ((int32_t*)dp3)[1],((int32_t*)dp3)[2],jwin_pal[jcBOXFG],jwin_pal[jcBOX],"%3dKB",zcmusic_bufsz);
5745 unscare_mouse();
5746 return D_O_K;
5747 }
5748
5749 static int32_t gamepad_btn_list[] =
5750 {
5751 6,
5752 7,8,9,10,11,12,13,14,15,16,17,
5753 18,19,20,21,22,23,24,25,26,27,28,
5754 29,30,31,32,33,34,35,36,37,38,39,
5755 -1
5756 };
5757
5758 static int32_t gamepad_dirs_list[] =
5759 {
5760 40,41,42,43,
5761 44,45,46,47,
5762 48,49,50,51,
5763 52,53,54,55,
5764 56,
5765 -1
5766 };
5767
5768 static TABPANEL gamepad_tabs[] =
5769 {
5770 // (text)
5771 { (char *)"Buttons", D_SELECTED, gamepad_btn_list, 0, NULL },
5772 { (char *)"Directions", 0, gamepad_dirs_list, 0, NULL },
5773 { NULL, 0, NULL, 0, NULL }
5774 };
5775
5776 static DIALOG gamepad_dlg[] =
5777 {
5778 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5779 { jwin_win_proc, 8, 24, 304, 256, 0, 0, 0, D_EXIT, 0, 0, (void *) "Gamepad Controls", NULL, NULL },
5780 { jwin_tab_proc, 8+4, 24+23,304-8,256-52,vc(0), vc(15), 0, 0, 0, 0, (void *) gamepad_tabs, NULL, (void *)gamepad_dlg },
5781 { d_stringloader, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5782 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5783 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5784 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5785 // 6
5786 { d_dummy_proc, 14, 61, 294, 192, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5787 // 7
5788 { jwin_ctext_proc, 92, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5789 { jwin_ctext_proc, 92, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5790 { jwin_ctext_proc, 92, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5791 { jwin_ctext_proc, 92, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5792 { jwin_ctext_proc, 92, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5793 { jwin_ctext_proc, 237, 92-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5794 { jwin_ctext_proc, 237, 120-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5795 { jwin_ctext_proc, 237, 148-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5796 { jwin_ctext_proc, 237, 180-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5797 { jwin_ctext_proc, 237, 212-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5798 { jwin_ctext_proc, 92, 244-20, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_m, NULL, NULL },
5799 // 18
5800 { d_jbutton_proc, 22, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Abtn},
5801 { d_jbutton_proc, 22, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bbtn},
5802 { d_jbutton_proc, 22, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Sbtn},
5803 { d_jbutton_proc, 22, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exbtn1},
5804 { d_jbutton_proc, 22, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exbtn3},
5805 { d_jbutton_proc, 167, 90-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lbtn},
5806 { d_jbutton_proc, 167, 118-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rbtn},
5807 { d_jbutton_proc, 167, 146-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pbtn},
5808 { d_jbutton_proc, 167, 178-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exbtn2},
5809 { d_jbutton_proc, 167, 210-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exbtn4},
5810 { d_jbutton_proc, 22, 242-20, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Menu", NULL, &Mbtn},
5811 // 29
5812 { d_j_clearbutton_proc, 22+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Abtn},
5813 { d_j_clearbutton_proc, 22+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bbtn},
5814 { d_j_clearbutton_proc, 22+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Sbtn},
5815 { d_j_clearbutton_proc, 22+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn1},
5816 { d_j_clearbutton_proc, 22+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn3},
5817 { d_j_clearbutton_proc, 167+91, 90-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lbtn},
5818 { d_j_clearbutton_proc, 167+91, 118-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rbtn},
5819 { d_j_clearbutton_proc, 167+91, 146-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pbtn},
5820 { d_j_clearbutton_proc, 167+91, 178-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn2},
5821 { d_j_clearbutton_proc, 167+91, 210-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exbtn4},
5822 { d_j_clearbutton_proc, 22+91, 242-20, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Mbtn},
5823 // 40
5824 { jwin_frame_proc, 14, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5825 { jwin_frame_proc, 159, 62, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5826 { jwin_text_proc, 30, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5827 { jwin_text_proc, 175, 68, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5828 // 44
5829 { jwin_text_proc, 92, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5830 { jwin_text_proc, 92, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5831 { jwin_text_proc, 237, 84, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5832 { jwin_text_proc, 237, 112, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5833 // 48
5834 { d_jbutton_proc, 22, 82, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUbtn },
5835 { d_jbutton_proc, 22, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDbtn },
5836 { d_jbutton_proc, 167, 82, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLbtn },
5837 { d_jbutton_proc, 167, 110, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRbtn },
5838 // 52
5839 { d_j_clearbutton_proc, 22+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUbtn},
5840 { d_j_clearbutton_proc, 22+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDbtn},
5841 { d_j_clearbutton_proc, 167+91, 82, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLbtn},
5842 { d_j_clearbutton_proc, 167+91, 110, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRbtn},
5843 // 56
5844 { jwin_check_proc, 22, 150, 147, 8, vc(14), vc(1), 0, 0, 1, 0, (void *) "Use Analog Stick/DPad", NULL, NULL },
5845 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5846 };
5847
5848 static int32_t keyboard_keys_list[] =
5849 {
5850 6,7,8,9,10,
5851 11,12,13,14,15,16,17,18,19,20,
5852 21,22,23,24,25,26,27,28,29,30,
5853 31,32,33,34,35,36,37,38,39,40,
5854 -1
5855 };
5856
5857 static int32_t keyboard_dirs_list[] =
5858 {
5859 41,42,43,44,
5860 45,46,47,48,
5861 49,50,51,52,
5862 53,54,55,56,
5863 -1
5864 };
5865
5866 static int32_t keyboard_mods_list[] =
5867 {
5868 57,58,59,60,
5869 61,62,63,64,
5870 65,66,67,68,
5871 69,70,71,72,
5872 -1
5873 };
5874
5875 static TABPANEL keyboard_control_tabs[] =
5876 {
5877 // (text)
5878 { (char *)"Keys", D_SELECTED, keyboard_keys_list, 0, NULL },
5879 { (char *)"Directions", 0, keyboard_dirs_list, 0, NULL },
5880 { (char *)"Cheat Mods", 0, keyboard_mods_list, 0, NULL },
5881 { NULL, 0, NULL, 0, NULL }
5882 };
5883
5884 static DIALOG keyboard_control_dlg[] =
5885 {
5886 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5887 { jwin_win_proc, 8, 39, 304, 240, 0, 0, 0, D_EXIT, 0, 0, (void *) "Keyboard Controls", NULL, NULL },
5888 { jwin_tab_proc, 8+4, 39+23,304-8,240-56,vc(0), vc(15), 0, 0, 0, 0, (void *) keyboard_control_tabs, NULL, (void *)keyboard_control_dlg },
5889 { d_stringloader, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5890 { jwin_button_proc, 90, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5891 { jwin_button_proc, 170, 254, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5892 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5893 // Keys
5894 // 6
5895 { jwin_frame_proc, 14, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5896 { jwin_frame_proc, 158, 80, 148, 105, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5897 { jwin_frame_proc, 14, 181, 292, 67, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5898 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Standard", NULL, NULL },
5899 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Extended", NULL, NULL },
5900 // 11
5901 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
5902 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_b, NULL, NULL },
5903 { jwin_text_proc, 92-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
5904 { jwin_text_proc, 92-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex1, NULL, NULL },
5905 { jwin_text_proc, 92-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex3, NULL, NULL },
5906 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_l, NULL, NULL },
5907 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_r, NULL, NULL },
5908 { jwin_text_proc, 237-4, 158, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_p, NULL, NULL },
5909 { jwin_text_proc, 237-4, 190, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex2, NULL, NULL },
5910 { jwin_text_proc, 237-4, 222, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_ex4, NULL, NULL },
5911 // 21
5912 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "A", NULL, &Akey},
5913 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "B", NULL, &Bkey},
5914 { d_kbutton_proc, 22, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Start", NULL, &Skey},
5915 { d_kbutton_proc, 22, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "X (EX1)", NULL, &Exkey1},
5916 { d_kbutton_proc, 22, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX3", NULL, &Exkey3},
5917 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "L", NULL, &Lkey},
5918 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "R", NULL, &Rkey},
5919 { d_kbutton_proc, 167, 156, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Map", NULL, &Pkey},
5920 { d_kbutton_proc, 167, 188, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Y (EX2)", NULL, &Exkey2},
5921 { d_kbutton_proc, 167, 220, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "EX4", NULL, &Exkey4},
5922 // 31
5923 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Akey},
5924 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Bkey},
5925 { d_k_clearbutton_proc, 22+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Skey},
5926 { d_k_clearbutton_proc, 22+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey1},
5927 { d_k_clearbutton_proc, 22+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey3},
5928 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Lkey},
5929 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Rkey},
5930 { d_k_clearbutton_proc, 167+91, 156, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Pkey},
5931 { d_k_clearbutton_proc, 167+91, 188, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey2},
5932 { d_k_clearbutton_proc, 167+91, 220, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &Exkey4},
5933 // Dirs
5934 // 41
5935 { jwin_frame_proc, 14, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5936 { jwin_frame_proc, 159, 80, 147, 80, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5937 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Vertical", NULL, NULL },
5938 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Horizontal", NULL, NULL },
5939 // 45
5940 { jwin_text_proc, 92-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_up, NULL, NULL },
5941 { jwin_text_proc, 92-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_down, NULL, NULL },
5942 { jwin_text_proc, 237-4, 102, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_left, NULL, NULL },
5943 { jwin_text_proc, 237-4, 130, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_right, NULL, NULL },
5944 // 49
5945 { d_kbutton_proc, 22, 100, 61, 21, vc(14), vc(11), 0, 0, 0, 0, (void *) "Up", NULL, &DUkey},
5946 { d_kbutton_proc, 22, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Down", NULL, &DDkey},
5947 { d_kbutton_proc, 167, 100, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Left", NULL, &DLkey},
5948 { d_kbutton_proc, 167, 128, 61, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Right", NULL, &DRkey},
5949 // 53
5950 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DUkey},
5951 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DDkey},
5952 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DLkey},
5953 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &DRkey},
5954 // Mods
5955 // 57
5956 { jwin_frame_proc, 14, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5957 { jwin_frame_proc, 158, 80, 148, 140-58, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
5958 { jwin_text_proc, 30, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Left", NULL, NULL },
5959 { jwin_text_proc, 175, 86, 160, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Right", NULL, NULL },
5960 // 61
5961 { jwin_text_proc, 92-26, 101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod1, NULL, NULL },
5962 { jwin_text_proc, 92-26, 129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod1, NULL, NULL },
5963 { jwin_text_proc, 237-4-22,101, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_leftmod2, NULL, NULL },
5964 { jwin_text_proc, 237-4-22,129, 60, 8, vc(7), vc(11), 0, 0, 0, 0, str_rightmod2, NULL, NULL },
5965 // 65
5966 { d_kbutton_proc, 22, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[0]},
5967 { d_kbutton_proc, 22, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[2]},
5968 { d_kbutton_proc, 167, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Main", NULL, &cheat_modifier_keys[1]},
5969 { d_kbutton_proc, 167, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Second", NULL, &cheat_modifier_keys[3]},
5970 // 69
5971 { d_k_clearbutton_proc, 22+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[0]},
5972 { d_k_clearbutton_proc, 22+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[2]},
5973 { d_k_clearbutton_proc, 167+91, 100, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[1]},
5974 { d_k_clearbutton_proc, 167+91, 128, 40, 21, vc(14), vc(1), 0, 0, 0, 0, (void *) "Clear", NULL, &cheat_modifier_keys[3]},
5975 // 73
5976 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
5977 };
5978
5979 /*
5980 int32_t midi_dp[3] = {0,147,104};
5981 int32_t digi_dp[3] = {1,147,120};
5982 int32_t pan_dp[3] = {0,147,136};
5983 int32_t buf_dp[3] = {0,147,152};
5984 */
5985 int32_t midi_dp[3] = {0,0,0};
5986 int32_t digi_dp[3] = {1,0,0};
5987 int32_t emus_dp[3] = {2,0,0};
5988 int32_t buf_dp[3] = {0,0,0};
5989 int32_t sfx_dp[3] = {3,0,0};
5990 int32_t pan_dp[3] = {0,0,0};
5991
5992 static DIALOG sound_dlg[] =
5993 {
5994 //(dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3)
5995 7 { jwin_win_proc, 0, 0, 320, 178, 0, 0, 0, D_EXIT, 0, 0, (void *) "Sound Settings", NULL, NULL },
5996 7 { d_stringloader, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
5997 7 { jwin_button_proc, 58, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
5998 7 { jwin_button_proc, 138, 148, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
5999 7 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6000 7 { jwin_frame_proc, 10, 28, 300, 112, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6001 7 { jwin_rtext_proc, 190, 40, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_a, NULL, NULL },
6002 7 { jwin_rtext_proc, 190, 56, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_b, NULL, NULL },
6003 7 { jwin_rtext_proc, 190, 72, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_l, NULL, NULL },
6004 7 { jwin_rtext_proc, 190, 88, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_m, NULL, NULL },
6005 // 10
6006 7 { jwin_rtext_proc, 190, 104, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_r, NULL, NULL },
6007 7 { jwin_rtext_proc, 190, 120, 40, 8, vc(7), vc(11), 0, 0, 0, 0, (void *) str_s, NULL, NULL },
6008 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6009 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6010 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6011 7 { jwin_slider_proc, 196, 40, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, midi_dp },
6012 7 { jwin_slider_proc, 196, 56, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, digi_dp },
6013 7 { jwin_slider_proc, 196, 72, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, emus_dp },
6014 7 { jwin_slider_proc, 196, 88, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 127, 0, NULL, (void *) set_buf, buf_dp },
6015 7 { jwin_slider_proc, 196, 104, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 32, 0, NULL, (void *) set_vol, sfx_dp },
6016 //20
6017 7 { jwin_slider_proc, 196, 120, 96, 8, vc(0), jwin_pal[jcBOX], 0, 0, 3, 0, NULL, (void *) set_pan, pan_dp },
6018 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6019 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6020 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6021 7 { jwin_text_proc, 17, 40, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master MIDI Volume", NULL, NULL },
6022 7 { jwin_text_proc, 17, 56, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Master Digi Volume", NULL, NULL },
6023 7 { jwin_text_proc, 17, 72, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Volume", NULL, NULL },
6024 7 { jwin_text_proc, 17, 88, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Enhanced Music Buffer", NULL, NULL },
6025 7 { jwin_text_proc, 17, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Volume", NULL, NULL },
6026 7 { jwin_text_proc, 17, 120, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "SFX Pan", NULL, NULL },
6027 //30
6028 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6029 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6030 7 { d_dummy_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6031 7 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6032 };
6033
6034 char zc_builddate[80];
6035 char zc_aboutstr[80];
6036
6037 static DIALOG about_dlg[] =
6038 {
6039 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6040 { jwin_win_proc, 68, 52, 184, 154, 0, 0, 0, D_EXIT, 0, 0, (void *) "About", NULL, NULL },
6041 { jwin_button_proc, 140, 176, 41, 21, vc(14), 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6042 { jwin_ctext_proc, 160, 84, 0, 8, vc(0), vc(11), 0, 0, 0, 0, zc_aboutstr, NULL, NULL },
6043 { jwin_ctext_proc, 160, 92, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6044 { jwin_ctext_proc, 160, 100, 0, 8, vc(0) , vc(11), 0, 0, 0, 0, zc_builddate, NULL, NULL },
6045 { jwin_text_proc, 88, 124, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Coded by:", NULL, NULL },
6046 { jwin_text_proc, 88, 132, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Phantom Menace", NULL, NULL },
6047 { jwin_text_proc, 88, 144, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Produced by:", NULL, NULL },
6048 { jwin_text_proc, 88, 152, 140, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) " Armageddon Games", NULL, NULL },
6049 { jwin_frame_proc, 80, 117, 160, 50, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6050 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6051 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6052 };
6053
6054
6055 static DIALOG quest_dlg[] =
6056 {
6057 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6058 { jwin_win_proc, 68, 25, 184, 190, 0, 0, 0, D_EXIT, 0, 0, (void *) "Quest Info", NULL, NULL },
6059 { jwin_edit_proc, 84, 54, 152, 16, 0, 0, 0, D_READONLY, 100, 0, NULL, NULL, NULL },
6060 { jwin_text_proc, 89, 84, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
6061 { jwin_text_proc, 152, 84, 24, 8, vc(7), vc(11), 0, 0, 0, 0, str_a, NULL, NULL },
6062 { jwin_text_proc, 89, 94, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Version:", NULL, NULL },
6063 { jwin_text_proc, 160, 94, 64, 8, vc(7), vc(11), 0, 0, 0, 0, QHeader.version, NULL, NULL },
6064 { jwin_text_proc, 89, 104, 141, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "ZQ Version:", NULL, NULL },
6065 { jwin_text_proc, 184, 104, 64, 8, vc(7), vc(11), 0, 0, 0, 0, str_s, NULL, NULL },
6066 { jwin_text_proc, 84, 126, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Title:", NULL, NULL },
6067 { jwin_textbox_proc, 84, 136, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.title, NULL, NULL },
6068 { jwin_text_proc, 84, 168, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Author:", NULL, NULL },
6069 { jwin_textbox_proc, 84, 178, 152, 24, 0, 0, 0, 0, 0, 0, QHeader.author, NULL, NULL },
6070 { jwin_frame_proc, 84, 79, 152, 38, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
6071 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6072 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6073 };
6074
6075 static DIALOG triforce_dlg[] =
6076 {
6077 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
6078 { jwin_win_proc, 72, 64, 177, 105, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Triforce Pieces", NULL, NULL },
6079 // 1
6080 { jwin_check_proc, 129, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "1", NULL, NULL },
6081 { jwin_check_proc, 129, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "2", NULL, NULL },
6082 { jwin_check_proc, 129, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "3", NULL, NULL },
6083 { jwin_check_proc, 129, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "4", NULL, NULL },
6084 { jwin_check_proc, 172, 94, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "5", NULL, NULL },
6085 { jwin_check_proc, 172, 104, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "6", NULL, NULL },
6086 { jwin_check_proc, 172, 114, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "7", NULL, NULL },
6087 { jwin_check_proc, 172, 124, 24, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "8", NULL, NULL },
6088 // 9
6089 { jwin_button_proc, 90, 144, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6090 { jwin_button_proc, 170, 144, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6091 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6092 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6093 };
6094
6095 /*static DIALOG equip_dlg[] =
6096 {
6097 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6098 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Equipment", NULL, NULL },
6099 // 1
6100 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6101 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6102 // 3
6103 { jwin_frame_proc, 25, 45, 77, 50, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6104 { jwin_text_proc, 29, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Sword", NULL, NULL },
6105 { jwin_check_proc, 33, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6106 { jwin_check_proc, 33, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "White", NULL, NULL },
6107 { jwin_check_proc, 33, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6108 { jwin_check_proc, 33, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Master", NULL, NULL },
6109 // 9
6110 { jwin_frame_proc, 25, 99, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6111 { jwin_text_proc, 29, 96, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Shield", NULL, NULL },
6112 { jwin_check_proc, 33, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6113 { jwin_check_proc, 33, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6114 { jwin_check_proc, 33, 126, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Mirror", NULL, NULL },
6115 // 14
6116 { jwin_frame_proc, 25, 143, 61, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6117 { jwin_text_proc, 29, 140, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Ring", NULL, NULL },
6118 { jwin_check_proc, 33, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6119 { jwin_check_proc, 33, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6120 { jwin_check_proc, 33, 170, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Gold", NULL, NULL },
6121 // 19
6122 { jwin_frame_proc, 110, 45, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6123 { jwin_text_proc, 114, 42, 64, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bracelet", NULL, NULL },
6124 { jwin_check_proc, 118, 52, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6125 { jwin_check_proc, 118, 62, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6126 // 23
6127 { jwin_frame_proc, 110, 79, 85, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6128 { jwin_text_proc, 114, 76, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Amulet", NULL, NULL },
6129 { jwin_check_proc, 118, 86, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6130 { jwin_check_proc, 118, 96, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 2", NULL, NULL },
6131 // 27
6132 { jwin_frame_proc, 110, 113, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6133 { jwin_text_proc, 114, 110, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Wallet", NULL, NULL },
6134 { jwin_check_proc, 118, 120, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6135 { jwin_check_proc, 118, 130, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6136 // 31
6137 { jwin_frame_proc, 110, 147, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6138 { jwin_text_proc, 114, 144, 24, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bow", NULL, NULL },
6139 { jwin_check_proc, 118, 154, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Small", NULL, NULL },
6140 { jwin_check_proc, 118, 164, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Large", NULL, NULL },
6141 // 35
6142 { jwin_frame_proc, 203, 45, 93, 70, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6143 { jwin_text_proc, 207, 42, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6144 { jwin_check_proc, 211, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Raft", NULL, NULL },
6145 { jwin_check_proc, 211, 62, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Ladder", NULL, NULL },
6146 { jwin_check_proc, 211, 72, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Book", NULL, NULL },
6147 { jwin_check_proc, 211, 82, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic Key", NULL, NULL },
6148 { jwin_check_proc, 211, 92, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Flippers", NULL, NULL },
6149 { jwin_check_proc, 211, 102, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Boots", NULL, NULL },
6150 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6151 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6152 };
6153
6154 static DIALOG items_dlg[] =
6155 {
6156 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6157 { jwin_win_proc, 16, 18, 289, 215, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Items", NULL, NULL },
6158 //1
6159 { jwin_button_proc, 90, 206, 61, 21, vc(0), vc(11), 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6160 { jwin_button_proc, 170, 206, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6161 // 3
6162 { jwin_frame_proc, 27, 45, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6163 { jwin_text_proc, 31, 42, 64, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Boomerang", NULL, NULL },
6164 { jwin_check_proc, 35, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6165 { jwin_check_proc, 35, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Magic", NULL, NULL },
6166 { jwin_check_proc, 35, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Fire", NULL, NULL },
6167 // 8
6168 { jwin_frame_proc, 27, 89, 77, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6169 { jwin_text_proc, 31, 86, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Arrow", NULL, NULL },
6170 { jwin_check_proc, 35, 96, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wooden", NULL, NULL },
6171 { jwin_check_proc, 35, 106, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Silver", NULL, NULL },
6172 { jwin_check_proc, 35, 116, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Golden", NULL, NULL },
6173 // 13
6174 { jwin_frame_proc, 27, 133, 63, 40, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6175 { jwin_text_proc, 31, 130, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Potion", NULL, NULL },
6176 { jwin_radio_proc, 35, 140, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "None", NULL, NULL },
6177 { jwin_radio_proc, 35, 150, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6178 { jwin_radio_proc, 35, 160, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6179 // 18
6180 { jwin_frame_proc, 114, 45, 93, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6181 { jwin_text_proc, 118, 42, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Whistle", NULL, NULL },
6182 { jwin_check_proc, 122, 52, 80, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Recorder", NULL, NULL },
6183 // 21
6184 { jwin_frame_proc, 114, 69, 86, 20, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6185 { jwin_text_proc, 118, 66, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hammer", NULL, NULL },
6186 { jwin_check_proc, 122, 76, 72, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Level 1", NULL, NULL },
6187 // 24
6188 { jwin_frame_proc, 114, 93, 69, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6189 { jwin_text_proc, 118, 90, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Hookshot", NULL, NULL },
6190 { jwin_check_proc, 122, 100, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Short", NULL, NULL },
6191 { jwin_check_proc, 122, 110, 56, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Long", NULL, NULL },
6192 // 28
6193 { jwin_frame_proc, 114, 127, 60, 30, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6194 { jwin_text_proc, 118, 124, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Candle", NULL, NULL },
6195 { jwin_check_proc, 122, 134, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Blue", NULL, NULL },
6196 { jwin_check_proc, 122, 144, 48, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Red", NULL, NULL },
6197 // 32
6198 { jwin_frame_proc, 217, 45, 77, 138, 0, 0, 0, 0, FR_ETCHED, 0, NULL, NULL, NULL },
6199 { jwin_text_proc, 221, 42, 80, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Other", NULL, NULL },
6200 { jwin_check_proc, 225, 52, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Bait", NULL, NULL },
6201 { jwin_check_proc, 225, 62, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Letter", NULL, NULL },
6202 { jwin_check_proc, 225, 72, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Wand", NULL, NULL },
6203 { jwin_check_proc, 225, 82, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Lens", NULL, NULL },
6204 { jwin_check_proc, 225, 92, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Din's Fire", NULL, NULL },
6205 { jwin_check_proc, 225, 102, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Farore's Wind", NULL, NULL },
6206 { jwin_check_proc, 225, 112, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Nayru's Love", NULL, NULL },
6207 { jwin_text_proc, 225, 132, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "Bombs:", NULL, NULL },
6208 { jwin_edit_proc, 229, 142, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6209 { jwin_text_proc, 225, 162, 48, 9, vc(0), vc(11), 0, 0, 0, 0, (void *) "S-Bombs:", NULL, NULL },
6210 { jwin_edit_proc, 229, 162, 40, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
6211 { jwin_check_proc, 225, 122, 64, 9, vc(0), vc(11), 0, 0, 1, 0, (void *) "Cane of Byrna", NULL, NULL },
6212 //45
6213 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6214 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6215 };*/
6216
6217
6218
6219 bool zc_getname(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6220 {
6221 go();
6222 int32_t ret=0;
6223 ret = zc_getname_nogo(prompt,ext,list,def,usefilename);
6224 comeback();
6225 return ret != 0;
6226 }
6227
6228
6229 bool zc_getname_nogo(const char *prompt,const char *ext,EXT_LIST *list,const char *def,bool usefilename)
6230 {
6231 if(def!=modulepath)
6232 strcpy(modulepath,def);
6233
6234 if(!usefilename)
6235 {
6236 int32_t i=(int32_t)strlen(modulepath);
6237
6238 while(i>=0 && modulepath[i]!='\\' && modulepath[i]!='/')
6239 modulepath[i--]=0;
6240 }
6241
6242 // int32_t ret = file_select_ex(prompt,modulepath,ext,255,-1,-1);
6243 int32_t ret=0;
6244 int32_t sel=0;
6245
6246 if(list==NULL)
6247 {
6248 ret = jwin_file_select_ex(prompt,modulepath,ext,2048,-1,-1,lfont);
6249 }
6250 else
6251 {
6252 ret = jwin_file_browse_ex(prompt, modulepath, list, &sel, 2048, -1, -1, lfont);
6253 }
6254
6255 return ret!=0;
6256 }
6257
6258 //The Dialogue that loads a ZMOD Module File
6259 int32_t zc_load_zmod_module_file()
6260 {
6261 if ( Playing )
6262 {
6263 jwin_alert("Error","Cannot change module while playing a quest!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6264 return -1;
6265 }
6266 if(!zc_getname("Load Module (.zmod)","zmod",NULL,modulepath,false))
6267 return D_CLOSE;
6268
6269 FILE *tempmodule = fopen(modulepath,"r");
6270
6271 if(tempmodule == NULL)
6272 {
6273 jwin_alert("Error","Cannot open specified file!",NULL,NULL,"O&K",NULL,'k',0,lfont);
6274 return -1;
6275 }
6276
6277
6278 //Set the module path:
6279 memset(moduledata.module_name, 0, sizeof(moduledata.module_name));
6280 strcpy(moduledata.module_name, modulepath);
6281 al_trace("New Module Path is: %s \n", moduledata.module_name);
6282 zc_set_config("ZCMODULE","current_module",moduledata.module_name);
6283 zcm.init(true); //Load the module values.
6284 moduledata.refresh_title_screen = 1;
6285 // refresh_select_screen = 1;
6286 build_biic_list();
6287 return D_O_K;
6288 }
6289
6290 static DIALOG module_info_dlg[] =
6291 {
6292 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
6293
6294
6295 { jwin_win_proc, 0, 0, 200, 200, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "About Current Module", NULL, NULL },
6296 //1
6297 { jwin_text_proc, 10, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Module:", NULL, NULL },
6298 //2
6299 { jwin_text_proc, 50, 20, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6300 { jwin_text_proc, 10, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Author:", NULL, NULL },
6301 //4
6302 { jwin_text_proc, 50, 30, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6303 { jwin_text_proc, 10, 40, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6304 { jwin_text_proc, 10, 50, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"Information:", NULL, NULL },
6305 //7
6306
6307 { jwin_text_proc, 10, 60, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6308 { jwin_text_proc, 10, 70, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6309 { jwin_text_proc, 10, 80, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6310 { jwin_text_proc, 10, 90, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6311 { jwin_text_proc, 10, 100, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6312 { jwin_text_proc, 10, 120, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6313 { jwin_text_proc, 10, 130, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6314 { jwin_text_proc, 10, 140, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6315 { jwin_text_proc, 10, 150, 20, 8, vc(11), vc(1), 0, 0, 0, 0, (void*)"", NULL, NULL },
6316
6317 { jwin_button_proc, 40, 160, 50, 21, vc(14), vc(1), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6318 { jwin_button_proc, 200-40-50, 160, 50, 21, vc(14), vc(1), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6319 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6320 };
6321
6322 void about_zcplayer_module(const char *prompt,int32_t initialval)
6323 {
6324
6325 module_info_dlg[0].dp2 = lfont;
6326 if ( moduledata.moduletitle[0] != 0 )
6327 module_info_dlg[2].dp = (char*)moduledata.moduletitle;
6328
6329 if ( moduledata.moduleauthor[0] != 0 )
6330 module_info_dlg[4].dp = (char*)moduledata.moduleauthor;
6331
6332 if ( moduledata.moduleinfo0[0] != 0 )
6333 module_info_dlg[7].dp = (char*)moduledata.moduleinfo0;
6334 if ( moduledata.moduleinfo1[0] != 0 )
6335 module_info_dlg[8].dp = (char*)moduledata.moduleinfo1;
6336 if ( moduledata.moduleinfo2[0] != 0 )
6337 module_info_dlg[9].dp = (char*)moduledata.moduleinfo2;
6338 if ( moduledata.moduleinfo3[0] != 0 )
6339 module_info_dlg[10].dp = (char*)moduledata.moduleinfo3;
6340 if ( moduledata.moduleinfo4[0] != 0 )
6341 module_info_dlg[11].dp = (char*)moduledata.moduleinfo4;
6342
6343 char module_date[255];
6344 memset(module_date, 0, sizeof(module_date));
6345 sprintf(module_date,"Build Date: %s %s, %d at @ %d:%d %s", dayextension(moduledata.modday).c_str(),
6346 (char*)months[moduledata.modmonth], moduledata.modyear, moduledata.modhour, moduledata.modminute, moduledata.moduletimezone);
6347
6348
6349
6350 char module_vers[255];
6351 memset(module_vers, 0, sizeof(module_vers));
6352 sprintf(module_vers, "Version: %d.%d.%d.%d", moduledata.modver_1, moduledata.modver_2, moduledata.modver_3, moduledata.modver_4);
6353
6354
6355 //sprintf(tilecount,"%d",1);
6356
6357 char module_build[255];
6358 memset(module_build, 0, sizeof(module_build));
6359 if ( moduledata.modbeta )
6360 sprintf(module_build,"Module Build: %d, %s: %d", moduledata.modbuild, (moduledata.modbeta<0) ? "Alpha" : "Beta", moduledata.modbeta );
6361 else
6362 sprintf(module_build,"Module Build: %d", moduledata.modbuild);
6363
6364 module_info_dlg[12].dp = (char*)module_date;
6365 module_info_dlg[13].dp = (char*)module_vers;
6366 module_info_dlg[14].dp = (char*)module_build;
6367
6368 if(is_large)
6369 large_dialog(module_info_dlg);
6370
6371 int32_t ret = zc_popup_dialog(module_info_dlg,-1);
6372 jwin_center_dialog(module_info_dlg);
6373
6374
6375 }
6376
6377 int32_t onAbout_ZCP_Module()
6378 {
6379 about_zcplayer_module("About Module (.zmod)", 0);
6380 return D_O_K;
6381 }
6382
6383 //New Modules Menu for 2.55+
6384 static MENU zcmodule_menu[] =
6385 {
6386 { (char *)"&Load Module...", zc_load_zmod_module_file, NULL, 0, NULL },
6387 { (char *)"&About Module", onAbout_ZCP_Module, NULL, 0, NULL },
6388
6389 { NULL, NULL, NULL, 0, NULL }
6390 };
6391
6392 int32_t onToggleRecordingNewSaves()
6393 {
6394 if (zc_get_config("zeldadx", "replay_new_saves", false))
6395 {
6396 zc_set_config("zeldadx", "replay_new_saves", false);
6397 }
6398 else
6399 {
6400 zc_set_config("zeldadx", "replay_new_saves", true);
6401 jwin_alert("Recording", "Newly created saves will be recorded and written to a replay file.",
6402 NULL,NULL,"OK",NULL,13,27,lfont);
6403 }
6404 return D_O_K;
6405 }
6406
6407 int32_t onStopReplayOrRecord()
6408 {
6409 if (replay_is_replaying())
6410 {
6411 replay_quit();
6412 }
6413 else if (replay_get_mode() == ReplayMode::Record)
6414 {
6415 if (!replay_get_meta_bool("test_mode"))
6416 {
6417 jwin_alert("Recording", "You cannot stop recording a save file.",
6418 NULL,NULL,"OK",NULL,13,27,lfont);
6419 return D_CLOSE;
6420 }
6421
6422 if (jwin_alert("Stop Recording",
6423 "Save replay to disk and stop recording?",
6424 "This will stop the recording.",
6425 NULL,
6426 "Yes","No",13,27,lfont) != 1)
6427 return D_CLOSE;
6428
6429 replay_save();
6430 replay_stop();
6431 }
6432 return D_O_K;
6433 }
6434
6435 static int32_t handle_on_load_replay(ReplayMode mode)
6436 {
6437 if (Playing)
6438 {
6439 if (jwin_alert("Replay - Warning!",
6440 "Loading a replay will exit the current game.",
6441 "All unsaved progress will be lost.",
6442 "Do you wish to continue?",
6443 "Yes","No",13,27,lfont) != 1)
6444 return D_CLOSE;
6445 }
6446
6447 std::string mode_string = replay_mode_to_string(mode);
6448 mode_string[0] = std::toupper(mode_string[0]);
6449
6450 std::string line_1 = "Select a replay file to play back.";
6451 std::string line_2 = "You won't be able to save, and it won't effect existing saves.";
6452 std::string line_3 = "You can stop the replay and take over manually any time.";
6453 if (mode == ReplayMode::Update)
6454 {
6455 line_1 = "Select a replay file to update.";
6456 line_2 = "WARNING: be sure to back up the zplay file";
6457 line_3 = "and verify that the updated replay works as expected!";
6458 }
6459
6460 if (jwin_alert(mode_string.c_str(),
6461 line_1.c_str(),
6462 line_2.c_str(),
6463 line_3.c_str(),
6464 "OK","Nevermind",13,27,lfont) == 1)
6465 {
6466 char replay_path[2048];
6467 strcpy(replay_path, "replays/");
6468 if (jwin_file_select_ex(
6469 fmt::format("Load Replay (.{})", REPLAY_EXTENSION).c_str(),
6470 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6471 return D_CLOSE;
6472
6473 replay_quit();
6474 load_replay_file_deferred(mode, replay_path);
6475 Quit = qRESET;
6476 return D_CLOSE;
6477 }
6478 return D_O_K;
6479 }
6480
6481 int32_t onLoadReplay()
6482 {
6483 return handle_on_load_replay(ReplayMode::Replay);
6484 }
6485
6486 int32_t onLoadReplayAssert()
6487 {
6488 return handle_on_load_replay(ReplayMode::Assert);
6489 }
6490
6491 int32_t onLoadReplayUpdate()
6492 {
6493 return handle_on_load_replay(ReplayMode::Update);
6494 }
6495
6496 int32_t onSaveReplay()
6497 {
6498 if (replay_get_mode() == ReplayMode::Record)
6499 {
6500 if (!replay_get_meta_bool("test_mode"))
6501 {
6502 if (jwin_alert("Save Replay",
6503 "This will save a copy of the replay up to this point.",
6504 "The official replay file will be untouched.",
6505 "Do you wish to continue?",
6506 "Yes","No",13,27,lfont) != 1)
6507 return D_CLOSE;
6508
6509 char replay_path[2048];
6510 strcpy(replay_path, replay_get_filename().c_str());
6511 if (jwin_file_select_ex(
6512 fmt::format("Save Replay (.{})", REPLAY_EXTENSION).c_str(),
6513 replay_path, REPLAY_EXTENSION.c_str(), 2048, -1, -1, lfont) == 0)
6514 return D_CLOSE;
6515
6516 if (fileexists(replay_path))
6517 {
6518 jwin_alert("Save Replay", "You cannot overwrite an existing file.",
6519 NULL,NULL,"OK",NULL,13,27,lfont);
6520 return D_CLOSE;
6521 }
6522
6523 replay_save(replay_path);
6524 }
6525 else
6526 {
6527 replay_save();
6528 }
6529 }
6530 return D_O_K;
6531 }
6532
6533 static MENU replay_menu[] =
6534 {
6535 { (char *)"Record new saves", onToggleRecordingNewSaves, NULL, 0, NULL },
6536 { (char *)"Stop replay", onStopReplayOrRecord, NULL, 0, NULL },
6537 { (char *)"Load replay", onLoadReplay, NULL, 0, NULL },
6538 { (char *)"Load replay (assert)", onLoadReplayAssert, NULL, 0, NULL },
6539 { (char *)"Load replay (update)", onLoadReplayUpdate, NULL, 0, NULL },
6540 { (char *)"Save replay", onSaveReplay, NULL, 0, NULL },
6541
6542 { NULL, NULL, NULL, 0, NULL }
6543 };
6544
6545 static DIALOG credits_dlg[] =
6546 {
6547 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6548 { jwin_win_proc, 40, 38, 241, 173, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "Zelda Classic Credits", NULL, NULL },
6549 { jwin_frame_proc, 47, 65, 227, 115, vc(15), vc(1), 0, 0, FR_DEEP, 0, NULL, NULL, NULL },
6550 { d_bitmap_proc, 49, 67, 222, 110, vc(15), vc(1), 0, 0, 0, 0, NULL, NULL, NULL },
6551 { jwin_button_proc, 140, 184, 41, 21, vc(14), vc(1), 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6552 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6553 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6554 };
6555
6556 7 static ListData dmap_list(dmaplist, &font);
6557
6558 static DIALOG goto_dlg[] =
6559 {
6560 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6561 { jwin_win_proc, 48, 25, 205, 100, 0, 0, 0, D_EXIT, 0, 0, (void *) "Goto Location", NULL, NULL },
6562 { jwin_button_proc, 90, 176-78, 61, 21, vc(14), 0, 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
6563 { jwin_button_proc, 170, 176-78, 61, 21, vc(14), 0, 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
6564 { jwin_text_proc, 55, 129-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "DMap:", NULL, NULL },
6565 { jwin_droplist_proc, 88, 126-75, 160, 16, 0, 0, 0, 0, 0, 0, (void *) &dmap_list, NULL, NULL },
6566 { jwin_text_proc, 55, 149-75, 80, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Screen:", NULL, NULL },
6567 { jwin_edit_proc, 132, 146-75, 91, 16, 0, 0, 0, 0, 2, 0, NULL, NULL, NULL },
6568 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6569 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6570 };
6571
6572 int32_t onGoTo()
6573 {
6574 bool music = false;
6575 music = music;
6576 sprintf(cheat_goto_screen_str,"%X",cheat_goto_screen);
6577
6578 goto_dlg[0].dp2=lfont;
6579 goto_dlg[4].d2=cheat_goto_dmap;
6580 goto_dlg[6].dp=cheat_goto_screen_str;
6581
6582 clear_keybuf();
6583
6584 if(is_large)
6585 large_dialog(goto_dlg);
6586
6587 if(zc_popup_dialog(goto_dlg,4)==1)
6588 {
6589 // dmap, screen
6590 cheats_enqueue(Cheat::GoTo, goto_dlg[4].d2, zc_min(zc_xtoi(cheat_goto_screen_str),0x7F));
6591 };
6592
6593 return D_O_K;
6594 }
6595
6596 int32_t onGoToComplete()
6597 {
6598 if(!Playing)
6599 {
6600 return D_O_K;
6601 }
6602
6603 system_pal();
6604 music_pause();
6605 pause_all_sfx();
6606 show_mouse(screen);
6607 onGoTo();
6608 eat_buttons();
6609
6610 zc_readrawkey(KEY_ESC);
6611
6612 show_mouse(NULL);
6613 game_pal();
6614 music_resume();
6615 resume_all_sfx();
6616 return D_O_K;
6617 }
6618
6619 int32_t onCredits()
6620 {
6621 go();
6622
6623 BITMAP *win = create_bitmap_ex(8,222,110);
6624
6625 if(!win)
6626 return D_O_K;
6627
6628 int32_t c=0;
6629 int32_t l=0;
6630 int32_t ol=-1;
6631 RLE_SPRITE *rle = (RLE_SPRITE*)(datafile[RLE_CREDITS].dat);
6632 RGB *pal = (RGB*)(datafile[PAL_CREDITS].dat);
6633 PALETTE tmppal;
6634
6635 rti_gui.transparency_index = 1;
6636
6637 clear_to_color(win, rti_gui.transparency_index);
6638 draw_rle_sprite(win,rle,0,0);
6639 credits_dlg[0].dp2=lfont;
6640 credits_dlg[1].fg = jwin_pal[jcDISABLED_FG];
6641 credits_dlg[2].dp = win;
6642
6643 set_palette_range(black_palette,0,127,false);
6644
6645 DIALOG_PLAYER *p = init_dialog(credits_dlg,3);
6646
6647 BITMAP* old_screen = screen;
6648 BITMAP* gui_bmp = zc_get_gui_bmp();
6649 ASSERT(gui_bmp);
6650 clear_to_color(gui_bmp, rti_gui.transparency_index);
6651 screen = gui_bmp;
6652
6653 while(update_dialog(p))
6654 {
6655 throttleFPS();
6656 ++c;
6657 l = zc_max((c>>1)-30,0);
6658
6659 if(l > rle->h)
6660 l = c = 0;
6661
6662 if(l > rle->h - 112)
6663 l = rle->h - 112;
6664
6665 clear_bitmap(win);
6666 draw_rle_sprite(win,rle,0,0-l);
6667
6668 if(c<=64)
6669 fade_interpolate(black_palette,pal,tmppal,c,0,127);
6670
6671 set_palette_range(tmppal,0,127,false);
6672
6673 if(l!=ol)
6674 {
6675 scare_mouse();
6676 d_bitmap_proc(MSG_DRAW,credits_dlg+2,0);
6677 unscare_mouse();
6678 SCRFIX();
6679 ol=l;
6680 }
6681
6682 update_hw_screen();
6683 }
6684
6685 screen = old_screen;
6686 system_pal();
6687
6688 shutdown_dialog(p);
6689 destroy_bitmap(win);
6690 //comeback();
6691
6692 rti_gui.transparency_index = 0;
6693
6694 return D_O_K;
6695 }
6696
6697 const char *midilist(int32_t index, int32_t *list_size)
6698 {
6699 if(index<0)
6700 {
6701 *list_size=0;
6702
6703 for(int32_t i=0; i<MAXMIDIS; i++)
6704 if(tunes[i].data)
6705 ++(*list_size);
6706
6707 return NULL;
6708 }
6709
6710 int32_t i=0,m=0;
6711
6712 while(m<=index && i<=MAXMIDIS)
6713 {
6714 if(tunes[i].data)
6715 ++m;
6716
6717 ++i;
6718 }
6719
6720 --i;
6721
6722 if(i==MAXMIDIS && m<index)
6723 return "(null)";
6724
6725 return tunes[i].title;
6726 }
6727
6728 /* ------- MIDI info stuff -------- */
6729
6730 char *text;
6731 midi_info *zmi;
6732 bool dialog_running;
6733 bool listening;
6734
6735 void get_info(int32_t index);
6736
6737 int32_t d_midilist_proc(int32_t msg,DIALOG *d,int32_t c)
6738 {
6739 int32_t d2 = d->d2;
6740 int32_t ret = jwin_droplist_proc(msg,d,c);
6741
6742 if(d2!=d->d2)
6743 {
6744 get_info(d->d2);
6745 }
6746
6747 return ret;
6748 }
6749
6750 int32_t d_listen_proc(int32_t msg,DIALOG *d,int32_t c)
6751 {
6752 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6753
6754 int32_t ret = jwin_button_proc(msg,d,c);
6755
6756 if(ret == D_CLOSE)
6757 {
6758 // get current midi index
6759 int32_t index = (d+(d->d1))->d2;
6760 int32_t i=0, m=0;
6761
6762 while(m<=index && i<=MAXMIDIS)
6763 {
6764 if(tunes[i].data)
6765 ++m;
6766
6767 ++i;
6768 }
6769
6770 --i;
6771 jukebox(i);
6772 listening = true;
6773 ret = D_O_K;
6774 }
6775
6776 return ret;
6777 }
6778
6779 int32_t d_savemidi_proc(int32_t msg,DIALOG *d,int32_t c)
6780 {
6781 /* 'd->d1' is offset from 'd' in DIALOG array to midilist proc */
6782
6783 int32_t ret = jwin_button_proc(msg,d,c);
6784
6785 if(ret == D_CLOSE)
6786 {
6787 // get current midi index
6788 int32_t index = (d+(d->d1))->d2;
6789 int32_t i=0, m=0;
6790
6791 while(m<=index && i<=MAXMIDIS)
6792 {
6793 if(tunes[i].data)
6794 ++m;
6795
6796 ++i;
6797 }
6798
6799 --i;
6800
6801 // get file name
6802
6803 int32_t sel=0;
6804 //struct ffblk f;
6805 char title[40] = "Save MIDI: ";
6806 char fname[2048];
6807 memset(fname,0,2048);
6808 static EXT_LIST list[] =
6809 {
6810 { (char *)"MIDI files (*.mid)", (char *)"mid" },
6811 { (char *)"HTML files (*.html, *.html)", (char *)"htm html" },
6812 { NULL, NULL }
6813 };
6814
6815 strcpy(title+11, tunes[i].title);
6816 title[39] = '\0';
6817
6818 if(jwin_file_browse_ex(title, fname, list, &sel, 2048, -1, -1, lfont)==0)
6819 goto done;
6820
6821 if(exists(fname))
6822 {
6823 if(jwin_alert(title, fname, "already exists.", "Overwrite it?", "&Yes","&No",'y','n',lfont)==2)
6824 goto done;
6825 }
6826
6827 // save midi i
6828
6829 if(save_midi(fname, (MIDI*)tunes[i].data) != 0)
6830 jwin_alert(title, "Error saving MIDI to", fname, NULL, "Darn", NULL,13,27,lfont);
6831
6832 done:
6833 chop_path(fname);
6834 ret = D_REDRAW;
6835 }
6836
6837 return ret;
6838 }
6839
6840 7 static ListData midi_list(midilist, &font);
6841
6842 static DIALOG midi_dlg[] =
6843 {
6844 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
6845 { jwin_win_proc, 8, 28, 304, 184, 0, 0, 0, D_EXIT, 0, 0, (void *) "MIDI Info", NULL, NULL },
6846 { jwin_text_proc, 32, 60, 40, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Tune:", NULL, NULL },
6847 { d_midilist_proc, 80, 56, 192, 16, 0, 0, 0, 0, 0, 0, (void *) &midi_list, NULL, NULL },
6848 { jwin_textbox_proc, 15, 80, 290, 96, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6849 { d_listen_proc, 24, 183, 72, 21, 0, 0, 'l', D_EXIT, -2, 0, (void *) "&Listen", NULL, NULL },
6850 { d_savemidi_proc, 108, 183, 72, 21, 0, 0, 's', D_EXIT, -3, 0, (void *) "&Save", NULL, NULL },
6851 { jwin_button_proc, 236, 183, 61, 21, 0, 0, 'k', D_EXIT, 0, 0, (void *) "O&K", NULL, NULL },
6852 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
6853 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
6854 };
6855
6856 void get_info(int32_t index)
6857 {
6858 int32_t i=0, m=0;
6859
6860 while(m<=index && i<=MAXMIDIS)
6861 {
6862 if(tunes[i].data)
6863 ++m;
6864
6865 ++i;
6866 }
6867
6868 --i;
6869
6870 if(i==MAXMIDIS && m<index)
6871 strcpy(text,"(null)");
6872 else
6873 {
6874 get_midi_info((MIDI*)tunes[i].data,zmi);
6875 get_midi_text((MIDI*)tunes[i].data,zmi,text);
6876 }
6877
6878 midi_dlg[0].dp2=lfont;
6879 midi_dlg[3].dp = text;
6880 midi_dlg[3].d1 = midi_dlg[3].d2 = 0;
6881 midi_dlg[5].flags = (tunes[i].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6882
6883 if(dialog_running)
6884 {
6885 scare_mouse();
6886 jwin_textbox_proc(MSG_DRAW,midi_dlg+3,0);
6887 d_savemidi_proc(MSG_DRAW,midi_dlg+5,0);
6888 unscare_mouse();
6889 }
6890 }
6891
6892 int32_t onMIDICredits()
6893 {
6894 text = (char*)malloc(4096);
6895 zmi = (midi_info*)malloc(sizeof(midi_info));
6896
6897 if(!text || !zmi)
6898 {
6899 jwin_alert(NULL,"Not enough memory",NULL,NULL,"OK",NULL,13,27,lfont);
6900 return D_O_K;
6901 }
6902
6903 bool do_pause_midi = midi_pos >= 0 && currmidi;
6904 auto restore_midi = currmidi;
6905 if(do_pause_midi)
6906 {
6907 paused_midi_pos = midi_pos;
6908 stop_midi();
6909 midi_paused=true;
6910 midi_suspended = midissuspHALTED;
6911 }
6912
6913 midi_dlg[0].dp2=lfont;
6914 midi_dlg[2].d1 = 0;
6915 midi_dlg[2].d2 = 0;
6916 midi_dlg[4].flags = D_EXIT;
6917 midi_dlg[5].flags = (tunes[midi_dlg[2].d1].flags&tfDISABLESAVE) ? D_DISABLED : D_EXIT;
6918
6919 listening = false;
6920 dialog_running=false;
6921 get_info(0);
6922
6923 dialog_running=true;
6924
6925 if(is_large)
6926 large_dialog(midi_dlg);
6927
6928 zc_popup_dialog(midi_dlg,0);
6929 dialog_running=false;
6930
6931 if(listening)
6932 music_stop();
6933
6934 if(do_pause_midi)
6935 {
6936 midi_suspended = midissuspRESUME;
6937 currmidi = restore_midi;
6938 midi_pos = paused_midi_pos;
6939 }
6940
6941 if(text) free(text);
6942 if(zmi) free(zmi);
6943 return D_O_K;
6944 }
6945
6946 int32_t onAbout()
6947 {
6948 char buf1[80]={0};
6949 std::ostringstream oss;
6950 sprintf(buf1,"%s (%s), Version: %s", ZC_PLAYER_NAME,PROJECT_NAME,ZC_PLAYER_V);
6951 oss << buf1 << '\n';
6952 sprintf(buf1, "%s, Build %d", ALPHA_VER_STR, VERSION_BUILD);
6953 oss << buf1 << '\n';
6954 sprintf(buf1,"Build Date: %s %s, %d at @ %s %s", dayextension(BUILDTM_DAY).c_str(), (char*)months[BUILDTM_MONTH], BUILDTM_YEAR, __TIME__, __TIMEZONE__);
6955 oss << buf1 << '\n';
6956 sprintf(buf1, "Built By: %s", DEV_SIGNOFF);
6957 oss << buf1 << '\n';
6958
6959 InfoDialog("About ZC", oss.str()).show();
6960 return D_O_K;
6961 }
6962
6963 int32_t onQuest()
6964 {
6965 char fname[100];
6966 strcpy(fname, get_filename(qstpath));
6967 quest_dlg[0].dp2=lfont;
6968 quest_dlg[1].dp = fname;
6969
6970 if(QHeader.quest_number==0)
6971 sprintf(str_a,"Custom");
6972 else
6973 sprintf(str_a,"%d",QHeader.quest_number);
6974
6975 sprintf(str_s,"%s",VerStr(QHeader.zelda_version));
6976
6977 quest_dlg[11].d1 = quest_dlg[9].d1 = 0;
6978 quest_dlg[11].d2 = quest_dlg[9].d2 = 0;
6979
6980 if(is_large)
6981 large_dialog(quest_dlg);
6982
6983 zc_popup_dialog(quest_dlg, 0);
6984 return D_O_K;
6985 }
6986
6987 void call_vidmode_dlg();
6988 int32_t onVidMode()
6989 {
6990 call_vidmode_dlg();
6991 return D_O_K;
6992 }
6993
6994 #define addToHash(c,b,h) if(h->find(c ## key) == h->end()) \
6995 {(*h)[c ## key]=true;} else { if ( c ## key != 0 ) b = false;}
6996 //Added an extra statement, so that if the key is cleared to 0, the cleared
6997 //keybinding status need not be unique. -Z ( 1st April, 2019 )
6998
6999 void load_ukeys(int32_t* arr)
7000 {
7001 arr[ukey_a] = Akey;
7002 arr[ukey_b] = Bkey;
7003 arr[ukey_s] = Skey;
7004 arr[ukey_l] = Lkey;
7005 arr[ukey_r] = Rkey;
7006 arr[ukey_p] = Pkey;
7007 arr[ukey_ex1] = Exkey1;
7008 arr[ukey_ex2] = Exkey2;
7009 arr[ukey_ex3] = Exkey3;
7010 arr[ukey_ex4] = Exkey4;
7011 arr[ukey_du] = DUkey;
7012 arr[ukey_dd] = DDkey;
7013 arr[ukey_dl] = DLkey;
7014 arr[ukey_dr] = DRkey;
7015 arr[ukey_mod1a] = cheat_modifier_keys[0];
7016 arr[ukey_mod1b] = cheat_modifier_keys[1];
7017 arr[ukey_mod2a] = cheat_modifier_keys[2];
7018 arr[ukey_mod2b] = cheat_modifier_keys[3];
7019 };
7020
7021 static const char* ukey_names[] = {
7022 "A", "B", "Start", "L", "R", "Map",
7023 "Ex1", "Ex2", "Ex3", "Ex4", "Up", "Down",
7024 "Left", "Right", "Cheat Mod L1", "Cheat Mod L2",
7025 "Cheat Mod R1", "Cheat Mod R2",
7026 };
7027 std::string get_ukey_name(int32_t k)
7028 {
7029 if (k < num_ukey) return ukey_names[k];
7030 return "";
7031 }
7032
7033 int32_t onKeyboard()
7034 {
7035 int32_t a = Akey;
7036 int32_t b = Bkey;
7037 int32_t s = Skey;
7038 int32_t l = Lkey;
7039 int32_t r = Rkey;
7040 int32_t p = Pkey;
7041 int32_t ex1 = Exkey1;
7042 int32_t ex2 = Exkey2;
7043 int32_t ex3 = Exkey3;
7044 int32_t ex4 = Exkey4;
7045 int32_t du = DUkey;
7046 int32_t dd = DDkey;
7047 int32_t dl = DLkey;
7048 int32_t dr = DRkey;
7049 int32_t mod1a = cheat_modifier_keys[0];
7050 int32_t mod1b = cheat_modifier_keys[1];
7051 int32_t mod2a = cheat_modifier_keys[2];
7052 int32_t mod2b = cheat_modifier_keys[3];
7053 bool done=false;
7054 int32_t ret;
7055
7056 keyboard_control_dlg[0].dp2=lfont;
7057
7058 if(is_large)
7059 large_dialog(keyboard_control_dlg);
7060
7061 while(!done)
7062 {
7063 ret = zc_popup_dialog(keyboard_control_dlg,3);
7064
7065 if(ret==3) // OK
7066 {
7067 int32_t ukeys[num_ukey];
7068 load_ukeys(ukeys);
7069 std::vector<std::string> uniqueError;
7070 for(int32_t q = 0; q < num_ukey; ++q)
7071 {
7072 for(int32_t p = q+1; p < num_ukey; ++p)
7073 {
7074 if(ukeys[q] == ukeys[p] && ukeys[q] != 0)
7075 {
7076 char buf[64];
7077 sprintf(buf, "'%s' conflicts with '%s'", get_ukey_name(q).c_str(), get_ukey_name(p).c_str());
7078 std::string str(buf);
7079 uniqueError.push_back(str);
7080 }
7081 }
7082 }
7083 if(uniqueError.size() == 0)
7084 {
7085 done = true;
7086 save_control_configs(true);
7087 }
7088 else
7089 {
7090 box_start(1, "Duplicate Keys", lfont, sfont, false, keyboard_control_dlg[0].w,keyboard_control_dlg[0].h, 2);
7091 box_out("Cannot have duplicate keybinds!"); box_eol();
7092 for(std::vector<std::string>::iterator it = uniqueError.begin();
7093 it != uniqueError.end(); ++it)
7094 {
7095 box_out((*it).c_str()); box_eol();
7096 }
7097 box_end(true);
7098 }
7099 /* Old uniqueness check
7100 std::map<int32_t,bool> *keyhash = new std::map<int32_t,bool>();
7101 bool unique = true;
7102 addToHash(A,unique,keyhash);
7103 addToHash(B,unique,keyhash);
7104 addToHash(S,unique,keyhash);
7105 addToHash(L,unique,keyhash);
7106 addToHash(R,unique,keyhash);
7107 addToHash(P,unique,keyhash);
7108 addToHash(DU,unique,keyhash);
7109 addToHash(DD,unique,keyhash);
7110 addToHash(DL,unique,keyhash);
7111 addToHash(DR,unique,keyhash);
7112
7113 if(keyhash->find(Exkey1) == keyhash->end())
7114 {
7115 (*keyhash)[Exkey1]=true;
7116 }
7117 else
7118 {
7119 if ( Exkey1 != 0 ) unique = false;
7120 }
7121
7122 if(keyhash->find(Exkey2) == keyhash->end())
7123 {
7124 (*keyhash)[Exkey2]=true;
7125 }
7126 else
7127 {
7128 if ( Exkey2 != 0 ) unique = false;
7129 }
7130
7131 if(keyhash->find(Exkey3) == keyhash->end())
7132 {
7133 (*keyhash)[Exkey3]=true;
7134 }
7135 else
7136 {
7137 if ( Exkey3 != 0 ) unique = false;
7138 }
7139
7140 if(keyhash->find(Exkey4) == keyhash->end())
7141 {
7142 (*keyhash)[Exkey4]=true;
7143 }
7144 else
7145 {
7146 if ( Exkey4 != 0 )unique = false;
7147 }
7148 //modifier keys
7149 if(keyhash->find(cheat_modifier_keys[0]) == keyhash->end())
7150 {
7151 (*keyhash)[cheat_modifier_keys[0]]=true;
7152 }
7153 else
7154 {
7155 if ( cheat_modifier_keys[0] != 0 ) unique = false;
7156 }
7157 if(keyhash->find(cheat_modifier_keys[1]) == keyhash->end())
7158 {
7159 (*keyhash)[cheat_modifier_keys[1]]=true;
7160 }
7161 else
7162 {
7163 if ( cheat_modifier_keys[1] != 0 ) unique = false;
7164 }
7165 if(keyhash->find(cheat_modifier_keys[2]) == keyhash->end())
7166 {
7167 (*keyhash)[cheat_modifier_keys[2]]=true;
7168 }
7169 else
7170 {
7171 if ( cheat_modifier_keys[2] != 0 ) unique = false;
7172 }
7173 if(keyhash->find(cheat_modifier_keys[3]) == keyhash->end())
7174 {
7175 (*keyhash)[cheat_modifier_keys[3]]=true;
7176 }
7177 else
7178 {
7179 if ( cheat_modifier_keys[3] != 0 ) unique = false;
7180 }
7181
7182 delete keyhash;
7183
7184 if(unique)
7185 done=true;
7186 else
7187 jwin_alert("Error", "Key bindings must be unique!", "", "", "OK",NULL,'o',0,lfont);
7188 */
7189 }
7190 else // Cancel
7191 {
7192 Akey = a;
7193 Bkey = b;
7194 Skey = s;
7195 Lkey = l;
7196 Rkey = r;
7197 Pkey = p;
7198 Exkey1 = ex1;
7199 Exkey2 = ex2;
7200 Exkey3 = ex3;
7201 Exkey4 = ex4;
7202 DUkey = du;
7203 DDkey = dd;
7204 DLkey = dl;
7205 DRkey = dr;
7206 cheat_modifier_keys[0] = mod1a;
7207 cheat_modifier_keys[1] = mod1b;
7208 cheat_modifier_keys[2] = mod2a;
7209 cheat_modifier_keys[3] = mod2b;
7210
7211 done=true;
7212 }
7213
7214 rest(1);
7215 }
7216
7217 return D_O_K;
7218 }
7219
7220 int32_t onGamepad()
7221 {
7222 int32_t a = Abtn;
7223 int32_t b = Bbtn;
7224 int32_t s = Sbtn;
7225 int32_t l = Lbtn;
7226 int32_t r = Rbtn;
7227 int32_t m = Mbtn;
7228 int32_t p = Pbtn;
7229 int32_t ex1 = Exbtn1;
7230 int32_t ex2 = Exbtn2;
7231 int32_t ex3 = Exbtn3;
7232 int32_t ex4 = Exbtn4;
7233 int32_t up = DUbtn;
7234 int32_t down = DDbtn;
7235 int32_t left = DLbtn;
7236 int32_t right = DRbtn;
7237
7238 gamepad_dlg[0].dp2=lfont;
7239 if(analog_movement)
7240 gamepad_dlg[56].flags|=D_SELECTED;
7241 else
7242 gamepad_dlg[56].flags&=~D_SELECTED;
7243
7244 if(is_large)
7245 large_dialog(gamepad_dlg);
7246
7247 int32_t ret = zc_popup_dialog(gamepad_dlg,4);
7248
7249 if(ret == 4) //OK
7250 {
7251 analog_movement = gamepad_dlg[56].flags&D_SELECTED;
7252 save_control_configs(false);
7253 }
7254 else //Cancel
7255 {
7256 Abtn = a;
7257 Bbtn = b;
7258 Sbtn = s;
7259 Lbtn = l;
7260 Rbtn = r;
7261 Mbtn = m;
7262 Pbtn = p;
7263 Exbtn1 = ex1;
7264 Exbtn2 = ex2;
7265 Exbtn3 = ex3;
7266 Exbtn4 = ex4;
7267 DUbtn = up;
7268 DDbtn = down;
7269 DLbtn = left;
7270 DRbtn = right;
7271 }
7272
7273 return D_O_K;
7274 }
7275
7276 int32_t onSound()
7277 {
7278 if ( FFCore.coreflags&FFCORE_SCRIPTED_MIDI_VOLUME )
7279 {
7280 master_volume(-1,((int32_t)FFCore.usr_midi_volume));
7281 }
7282 if ( FFCore.coreflags&FFCORE_SCRIPTED_DIGI_VOLUME )
7283 {
7284 master_volume((int32_t)(FFCore.usr_digi_volume),1);
7285 }
7286 if ( FFCore.coreflags&FFCORE_SCRIPTED_MUSIC_VOLUME )
7287 {
7288 emusic_volume = (int32_t)FFCore.usr_music_volume;
7289 }
7290 if ( FFCore.coreflags&FFCORE_SCRIPTED_SFX_VOLUME )
7291 {
7292 sfx_volume = (int32_t)FFCore.usr_sfx_volume;
7293 }
7294 if ( FFCore.coreflags&FFCORE_SCRIPTED_PANSTYLE )
7295 {
7296 pan_style = (int32_t)FFCore.usr_panstyle;
7297 }
7298
7299 int32_t m = midi_volume;
7300 int32_t d = digi_volume;
7301 int32_t e = emusic_volume;
7302 int32_t b = zcmusic_bufsz;
7303 int32_t s = sfx_volume;
7304 int32_t p = pan_style;
7305 pan_style = vbound(pan_style,0,3);
7306
7307 sound_dlg[0].dp2=lfont;
7308
7309 if(is_large)
7310 large_dialog(sound_dlg);
7311
7312 midi_dp[1] = sound_dlg[6].x;
7313 midi_dp[2] = sound_dlg[6].y;
7314 digi_dp[1] = sound_dlg[7].x;
7315 digi_dp[2] = sound_dlg[7].y;
7316 emus_dp[1] = sound_dlg[8].x;
7317 emus_dp[2] = sound_dlg[8].y;
7318 buf_dp[1] = sound_dlg[9].x;
7319 buf_dp[2] = sound_dlg[9].y;
7320 sfx_dp[1] = sound_dlg[10].x;
7321 sfx_dp[2] = sound_dlg[10].y;
7322 pan_dp[1] = sound_dlg[11].x;
7323 pan_dp[2] = sound_dlg[11].y;
7324 sound_dlg[15].d2 = (midi_volume==255) ? 32 : midi_volume>>3;
7325 sound_dlg[16].d2 = (digi_volume==255) ? 32 : digi_volume>>3;
7326 sound_dlg[17].d2 = (emusic_volume==255) ? 32 : emusic_volume>>3;
7327 sound_dlg[18].d2 = zcmusic_bufsz;
7328 sound_dlg[19].d2 = (sfx_volume==255) ? 32 : sfx_volume>>3;
7329 sound_dlg[20].d2 = pan_style;
7330
7331 int32_t ret = zc_popup_dialog(sound_dlg,1);
7332
7333 if(ret==2)
7334 {
7335 master_volume(digi_volume,midi_volume);
7336
7337 for(int32_t i=0; i<WAV_COUNT; ++i)
7338 {
7339 //allegro assertion fails when passing in -1 as voice -DD
7340 if(sfx_voice[i] > 0)
7341 voice_set_volume(sfx_voice[i], sfx_volume);
7342 }
7343 zc_set_config(sfx_sect,"digi",digi_volume);
7344 zc_set_config(sfx_sect,"midi",midi_volume);
7345 zc_set_config(sfx_sect,"sfx",sfx_volume);
7346 zc_set_config(sfx_sect,"emusic",emusic_volume);
7347 zc_set_config(sfx_sect,"pan",pan_style);
7348 zc_set_config(sfx_sect,"zcmusic_bufsz",zcmusic_bufsz);
7349 }
7350 else
7351 {
7352 midi_volume = m;
7353 digi_volume = d;
7354 emusic_volume = e;
7355 zcmusic_bufsz = b;
7356 sfx_volume = s;
7357 pan_style = p;
7358 }
7359
7360 return D_O_K;
7361 }
7362
7363 int32_t queding(char const* s1, char const* s2, char const* s3)
7364 {
7365 return jwin_alert(ZC_str,s1,s2,s3,"&Yes","&No",'y','n',lfont);
7366 }
7367
7368 int32_t onQuit()
7369 {
7370 if(Playing)
7371 {
7372 int32_t ret=0;
7373
7374 if(get_bit(quest_rules, qr_NOCONTINUE))
7375 {
7376 if(standalone_mode)
7377 {
7378 ret=queding("End current game?",
7379 "The continue screen is disabled; the game",
7380 "will be reloaded from the last save.");
7381 }
7382 else
7383 {
7384 ret=queding("End current game?",
7385 "The continue screen is disabled. You will",
7386 "be returned to the file select screen.");
7387 }
7388 }
7389 else
7390 ret=queding("End current game?",NULL,NULL);
7391
7392 if(ret==1)
7393 {
7394 disableClickToFreeze=false;
7395 Quit=qQUIT;
7396
7397 // Trying to evade a door repair charge?
7398 if(repaircharge)
7399 {
7400 game->change_drupy(-repaircharge);
7401 repaircharge=0;
7402 }
7403
7404 return D_CLOSE;
7405 }
7406 }
7407
7408 return D_O_K;
7409 }
7410
7411 int32_t onTryQuitMenu()
7412 {
7413 return onTryQuit(true);
7414 }
7415
7416 int32_t onTryQuit(bool inMenu)
7417 {
7418 if(Playing && !(GameFlags & GAMEFLAG_NO_F6))
7419 {
7420 if(get_bit(quest_rules,qr_OLD_F6))
7421 {
7422 if(inMenu) onQuit();
7423 else /*if(!get_bit(quest_rules, qr_NOCONTINUE))*/ f_Quit(qQUIT);
7424 }
7425 else
7426 {
7427 disableClickToFreeze=false;
7428 GameFlags |= GAMEFLAG_TRYQUIT;
7429 }
7430 return D_CLOSE;
7431 }
7432
7433 return D_O_K;
7434 }
7435
7436 int32_t onReset()
7437 {
7438 if(queding(" Reset system? ",NULL,NULL)==1)
7439 {
7440 disableClickToFreeze=false;
7441 Quit=qRESET;
7442 replay_quit();
7443 return D_CLOSE;
7444 }
7445
7446 return D_O_K;
7447 }
7448
7449 int32_t onExit()
7450 {
7451 if(queding(" Quit Zelda Classic? ",NULL,NULL)==1)
7452 {
7453 Quit=qEXIT;
7454 return D_CLOSE;
7455 }
7456
7457 return D_O_K;
7458 }
7459
7460 int32_t onTitle_NES()
7461 {
7462 title_version=0;
7463 zc_set_config(cfg_sect,"title",title_version);
7464 return D_O_K;
7465 }
7466 int32_t onTitle_DX()
7467 {
7468 title_version=1;
7469 zc_set_config(cfg_sect,"title",title_version);
7470 return D_O_K;
7471 }
7472 int32_t onTitle_25()
7473 {
7474 title_version=2;
7475 zc_set_config(cfg_sect,"title",title_version);
7476 return D_O_K;
7477 }
7478
7479 int32_t onDebug()
7480 {
7481 if(debug_enabled)
7482 set_debug(!get_debug());
7483 return D_O_K;
7484 }
7485
7486 int32_t onHeartBeep()
7487 {
7488 heart_beep=!heart_beep;
7489 zc_set_config(cfg_sect,"heart_beep",heart_beep);
7490 return D_O_K;
7491 }
7492
7493 int32_t onSaveIndicator()
7494 {
7495 use_save_indicator=!use_save_indicator;
7496 zc_set_config(cfg_sect,"save_indicator",use_save_indicator);
7497 return D_O_K;
7498 }
7499
7500 int32_t onEpilepsy()
7501 {
7502 if(jwin_alert3(
7503 "Epilepsy Flash Reduction",
7504 "Enabling this will reduce the intensity of flashing and screen wave effects.",
7505 "Disabling this will restore standard flash and wavy behaviour.",
7506 "Proceed?",
7507 "&Yes",
7508 "&No",
7509 NULL,
7510 'y',
7511 'n',
7512 0,
7513 lfont) == 1)
7514 {
7515 epilepsyFlashReduction = epilepsyFlashReduction ? 0 : 1;
7516 zc_set_config("zeldadx","checked_epilepsy",1);
7517 zc_set_config(cfg_sect,"epilepsy_flash_reduction",epilepsyFlashReduction);
7518 }
7519 return D_O_K;
7520 }
7521
7522 int32_t onTriforce()
7523 {
7524 for(int32_t i=0; i<MAXINITTABS; ++i)
7525 {
7526 init_tabs[i].flags&=~D_SELECTED;
7527 }
7528
7529 init_tabs[3].flags=D_SELECTED;
7530 return onCheatConsole();
7531 /*triforce_dlg[0].dp2=lfont;
7532 for(int32_t i=1; i<=8; i++)
7533 triforce_dlg[i].flags = (game->lvlitems[i] & liTRIFORCE) ? D_SELECTED : 0;
7534
7535 if(zc_popup_dialog (triforce_dlg,-1)==9)
7536 {
7537 for(int32_t i=1; i<=8; i++)
7538 {
7539 game->lvlitems[i] &= ~liTRIFORCE;
7540 game->lvlitems[i] |= (triforce_dlg[i].flags & D_SELECTED) ? liTRIFORCE : 0;
7541 }
7542 }
7543 return D_O_K;*/
7544 }
7545
7546 bool rc = false;
7547 /*
7548 int32_t onEquipment()
7549 {
7550 for (int32_t i=0; i<MAXINITTABS; ++i)
7551 {
7552 init_tabs[i].flags&=~D_SELECTED;
7553 }
7554 init_tabs[0].flags=D_SELECTED;
7555 return onCheatConsole();
7556 }
7557 */
7558
7559 int32_t onItems()
7560 {
7561 for(int32_t i=0; i<MAXINITTABS; ++i)
7562 {
7563 init_tabs[i].flags&=~D_SELECTED;
7564 }
7565
7566 init_tabs[1].flags=D_SELECTED;
7567 return onCheatConsole();
7568 }
7569
7570 static DIALOG getnum_dlg[] =
7571 {
7572 // (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp)
7573 { jwin_win_proc, 80, 80, 160, 72, vc(0), vc(11), 0, D_EXIT, 0, 0, NULL, NULL, NULL },
7574 { jwin_text_proc, 104, 104+4, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Number:", NULL, NULL },
7575 { jwin_edit_proc, 168, 104, 48, 16, 0, 0, 0, 0, 6, 0, NULL, NULL, NULL },
7576 { jwin_button_proc, 90, 126, 61, 21, vc(0), vc(11), 13, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7577 { jwin_button_proc, 170, 126, 61, 21, vc(0), vc(11), 27, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7578 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7579 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7580 };
7581
7582 int32_t getnumber(const char *prompt,int32_t initialval)
7583 {
7584 char buf[20];
7585 sprintf(buf,"%d",initialval);
7586 getnum_dlg[0].dp=(void *)prompt;
7587 getnum_dlg[0].dp2=lfont;
7588 getnum_dlg[2].dp=buf;
7589
7590 if(is_large)
7591 large_dialog(getnum_dlg);
7592
7593 if(zc_popup_dialog(getnum_dlg,2)==3)
7594 return atoi(buf);
7595
7596 return initialval;
7597 }
7598
7599 int32_t onLife()
7600 {
7601 int value = vbound(getnumber("Life",game->get_life()),1,game->get_maxlife());
7602 cheats_enqueue(Cheat::Life, value);
7603 return D_O_K;
7604 }
7605
7606 int32_t onHeartC()
7607 {
7608 int max_life = vbound(getnumber("Heart Containers",game->get_maxlife()/game->get_hp_per_heart()),1,4095) * game->get_hp_per_heart();
7609 int life = vbound(getnumber("Life",game->get_life()/game->get_hp_per_heart()),1,max_life/game->get_hp_per_heart())*game->get_hp_per_heart();
7610 cheats_enqueue(Cheat::MaxLife, max_life);
7611 cheats_enqueue(Cheat::Life, life);
7612 return D_O_K;
7613 }
7614
7615 int32_t onMagicC()
7616 {
7617 int max_magic = vbound(getnumber("Magic Containers",game->get_maxmagic()/game->get_mp_per_block()),0,2047) * game->get_mp_per_block();
7618 int magic = vbound(getnumber("Magic",game->get_magic()/game->get_mp_per_block()),0,game->get_maxmagic()/game->get_mp_per_block())*game->get_mp_per_block();
7619 cheats_enqueue(Cheat::MaxMagic, max_magic);
7620 cheats_enqueue(Cheat::Magic, magic);
7621 return D_O_K;
7622 }
7623
7624 int32_t onRupies()
7625 {
7626 int value = vbound(getnumber("Rupees",game->get_rupies()),0,game->get_maxcounter(1));
7627 cheats_enqueue(Cheat::Rupies, value);
7628 return D_O_K;
7629 }
7630
7631 int32_t onMaxBombs()
7632 {
7633 int value = vbound(getnumber("Max Bombs",game->get_maxbombs()),0,0xFFFF);
7634 cheats_enqueue(Cheat::MaxBombs, value);
7635 cheats_enqueue(Cheat::Bombs, value);
7636 return D_O_K;
7637 }
7638
7639 int32_t onRefillLife()
7640 {
7641 cheats_enqueue(Cheat::Life, game->get_maxlife());
7642 return D_O_K;
7643 }
7644 int32_t onRefillMagic()
7645 {
7646 cheats_enqueue(Cheat::Magic, game->get_maxmagic());
7647 return D_O_K;
7648 }
7649 int32_t onClock()
7650 {
7651 cheats_enqueue(Cheat::Clock);
7652 return D_O_K;
7653 }
7654
7655 int32_t onQstPath()
7656 {
7657 char path[2048];
7658
7659 chop_path(qstdir);
7660 strcpy(path,qstdir);
7661
7662 go();
7663
7664 if(jwin_dfile_select_ex("Quest File Directory", path, "qst", 2048, -1, -1, lfont))
7665 {
7666 chop_path(path);
7667 fix_filename_case(path);
7668 fix_filename_slashes(path);
7669 strcpy(qstdir,path);
7670 strcpy(qstpath,qstdir);
7671 }
7672
7673 comeback();
7674 return D_O_K;
7675 }
7676
7677 #include "dialog/cheat_dialog.h"
7678 int32_t onCheat()
7679 {
7680 call_setcheat_dialog();
7681 game->set_cheat(maxcheat);
7682 if(cheat) game->did_cheat(true);
7683 return D_O_K;
7684 }
7685
7686 int32_t onCheatRupies()
7687 {
7688 cheats_enqueue(Cheat::Rupies, game->get_maxcounter(1));
7689 return D_O_K;
7690 }
7691
7692 int32_t onCheatArrows()
7693 {
7694 cheats_enqueue(Cheat::Arrows, game->get_maxarrows());
7695 return D_O_K;
7696 }
7697
7698 int32_t onCheatBombs()
7699 {
7700 cheats_enqueue(Cheat::Bombs, game->get_maxbombs(), game->get_maxcounter(6));
7701 return D_O_K;
7702 }
7703
7704 // *** screen saver
7705
7706 208524 int32_t after_time()
7707 {
7708
1/2
✓ Branch 0 taken 208524 times.
✗ Branch 1 not taken.
208524 if(ss_enable == 0)
7709 return INT_MAX;
7710
7711
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
208524 if(ss_after <= 0)
7712 return 5 * 60;
7713
7714
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
208524 if(ss_after <= 3)
7715 return ss_after * 15 * 60;
7716
7717
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208524 times.
208524 if(ss_after <= 13)
7718 return (ss_after - 3) * 60 * 60;
7719
7720 208524 return MAX_IDLE + 1;
7721 208524 }
7722
7723 static const char *after_str[15] =
7724 {
7725 " 5 sec", "15 sec", "30 sec", "45 sec", " 1 min", " 2 min", " 3 min",
7726 " 4 min", " 5 min", " 6 min", " 7 min", " 8 min", " 9 min", "10 min",
7727 "Never"
7728 };
7729
7730 const char *after_list(int32_t index, int32_t *list_size)
7731 {
7732 if(index < 0)
7733 {
7734 *list_size = 15;
7735 return NULL;
7736 }
7737
7738 return after_str[index];
7739 }
7740
7741 7 static ListData after__list(after_list, &font);
7742
7743 static DIALOG scrsaver_dlg[] =
7744 {
7745 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) (dp2) (dp3) */
7746 7 { jwin_win_proc, 32, 64, 256, 136, 0, 0, 0, D_EXIT, 0, 0, (void *) "Screen Saver Settings", NULL, NULL },
7747 7 { jwin_frame_proc, 42, 92, 236, 70, 0, 0, 0, 0, FR_ETCHED,0, NULL, NULL, NULL },
7748 7 { jwin_text_proc, 60, 104, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Run After", NULL, NULL },
7749 7 { jwin_text_proc, 60, 128, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Speed", NULL, NULL },
7750 7 { jwin_text_proc, 60, 144, 48, 8, vc(0), vc(11), 0, 0, 0, 0, (void *) "Density", NULL, NULL },
7751 7 { jwin_droplist_proc, 144, 100, 96, 16, 0, 0, 0, 0, 0, 0, (void *) &after__list, NULL, NULL },
7752 7 { jwin_slider_proc, 144, 128, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7753 7 { jwin_slider_proc, 144, 144, 116, 8, vc(0), jwin_pal[jcBOX], 0, 0, 6, 0, NULL, NULL, NULL },
7754 7 { jwin_button_proc, 42, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "OK", NULL, NULL },
7755 7 { jwin_button_proc, 124, 170, 72, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Preview", NULL, NULL },
7756 7 { jwin_button_proc, 218, 170, 61, 21, 0, 0, 0, D_EXIT, 0, 0, (void *) "Cancel", NULL, NULL },
7757 7 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
7758 7 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
7759 };
7760
7761 int32_t onScreenSaver()
7762 {
7763 scrsaver_dlg[0].dp2=lfont;
7764 int32_t oldcfgs[3];
7765 scrsaver_dlg[5].d1 = scrsaver_dlg[5].d2 = oldcfgs[0] = ss_after;
7766 scrsaver_dlg[6].d2 = oldcfgs[1] = ss_speed;
7767 scrsaver_dlg[7].d2 = oldcfgs[2] = ss_density;
7768
7769 if(is_large)
7770 large_dialog(scrsaver_dlg);
7771
7772 int32_t ret = zc_popup_dialog(scrsaver_dlg,-1);
7773
7774 if(ret == 8 || ret == 9)
7775 {
7776 ss_after = scrsaver_dlg[5].d1;
7777 ss_speed = scrsaver_dlg[6].d2;
7778 ss_density = scrsaver_dlg[7].d2;
7779 if(oldcfgs[0] != ss_after)
7780 zc_set_config(cfg_sect,"ss_after",ss_after);
7781 if(oldcfgs[1] != ss_speed)
7782 zc_set_config(cfg_sect,"ss_speed",ss_speed);
7783 if(oldcfgs[2] != ss_density)
7784 zc_set_config(cfg_sect,"ss_density",ss_density);
7785 }
7786
7787 if(ret == 9)
7788 // preview Screen Saver
7789 {
7790 clear_keybuf();
7791 scare_mouse();
7792 Matrix(ss_speed, ss_density, 30);
7793 system_pal();
7794 unscare_mouse();
7795 }
7796
7797 return D_O_K;
7798 }
7799
7800 /***** Menus *****/
7801
7802 static MENU game_menu[] =
7803 {
7804 { (char *)"&Continue\tESC", onContinue, NULL, 0, NULL },
7805 { (char *)"", NULL, NULL, 0, NULL },
7806 { (char *)"L&oad Quest...", onCustomGame, NULL, 0, NULL },
7807 { (char *)"&End Game\tF6", onTryQuitMenu, NULL, 0, NULL },
7808 { (char *)"", NULL, NULL, 0, NULL },
7809 #ifdef __EMSCRIPTEN__
7810 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7811 #elif defined(ALLEGRO_MACOSX)
7812 { (char *)"&Reset\tF7", onReset, NULL, 0, NULL },
7813 { (char *)"&Quit\tF8", onExit, NULL, 0, NULL },
7814 #else
7815 { (char *)"&Reset\tF9", onReset, NULL, 0, NULL },
7816 { (char *)"&Quit\tF10", onExit, NULL, 0, NULL },
7817 #endif
7818 { NULL, NULL, NULL, 0, NULL }
7819 };
7820
7821 static MENU title_menu[] =
7822 {
7823 { (char *)"&Original", onTitle_NES, NULL, 0, NULL },
7824 { (char *)"&Zelda Classic", onTitle_DX, NULL, 0, NULL },
7825 { (char *)"Zelda Classic &2.50", onTitle_25, NULL, 0, NULL },
7826 { NULL, NULL, NULL, 0, NULL }
7827 };
7828
7829 static MENU snapshot_format_menu[] =
7830 {
7831 { (char *)"&BMP", onSetSnapshotFormat, NULL, 0, NULL },
7832 { (char *)"&GIF", onSetSnapshotFormat, NULL, 0, NULL },
7833 { (char *)"&JPG", onSetSnapshotFormat, NULL, 0, NULL },
7834 { (char *)"&PNG", onSetSnapshotFormat, NULL, 0, NULL },
7835 { (char *)"PC&X", onSetSnapshotFormat, NULL, 0, NULL },
7836 { (char *)"&TGA", onSetSnapshotFormat, NULL, 0, NULL },
7837 { NULL, NULL, NULL, 0, NULL }
7838 };
7839
7840 static MENU controls_menu[] =
7841 {
7842 { (char *)"Key&board...", onKeyboard, NULL, 0, NULL },
7843 { (char *)"&Gamepad...", onGamepad, NULL, 0, NULL },
7844 { NULL, NULL, NULL, 0, NULL }
7845 };
7846
7847 static MENU name_entry_mode_menu[] =
7848 {
7849 { (char *)"&Keyboard", onKeyboardEntry, NULL, 0, NULL },
7850 { (char *)"&Letter Grid", onLetterGridEntry, NULL, 0, NULL },
7851 { (char *)"&Extended Letter Grid", onExtLetterGridEntry, NULL, 0, NULL },
7852 { NULL, NULL, NULL, 0, NULL }
7853 };
7854
7855 static void set_controls_menu_active()
7856 {
7857
7858 }
7859
7860 static MENU settings_menu[] =
7861 {
7862 { (char *)"&Sound...", onSound, NULL, 0, NULL },
7863 { (char *)"C&ontrols", NULL, controls_menu, 0, NULL },
7864 { (char *)"&Title Screen", NULL, title_menu, 0, NULL },
7865 { (char *)"Name &Entry Mode", NULL, name_entry_mode_menu, 0, NULL },
7866 { (char *)"", NULL, NULL, 0, NULL },
7867 { (char *)"&Cap FPS\tF1", onVsync, NULL, 0, NULL },
7868 { (char *)"Show &FPS\tF2", onShowFPS, NULL, 0, NULL },
7869 { (char *)"Show Trans. &Layers", onTransLayers, NULL, 0, NULL },
7870 { (char *)"Up+A+B To &Quit", onNESquit, NULL, 0, NULL },
7871 { (char *)"Click to Freeze", onClickToFreeze, NULL, 0, NULL },
7872 { (char *)"Autosave Window Size Changes", onSaveDragResize, NULL, 0, NULL },
7873 { (char *)"Lock Aspect Ratio", onDragAspect, NULL, 0, NULL },
7874 { (char *)"Window Position Saving", onWinPosSave, NULL, 0, NULL },
7875 { (char *)"Volume &Keys", onVolKeys, NULL, 0, NULL },
7876 { (char *)"Cont. &Heart Beep", onHeartBeep, NULL, 0, NULL },
7877 { (char *)"Sa&ve Indicator", onSaveIndicator, NULL, 0, NULL },
7878 { (char *)"Epilepsy Flash Reduction", onEpilepsy, NULL, 0, NULL },
7879 { (char *)"S&napshot Format", NULL, snapshot_format_menu, 0, NULL },
7880 { (char *)"", NULL, NULL, 0, NULL },
7881 { (char *)"Debu&g", onDebug, NULL, 0, NULL },
7882 { (char *)"", NULL, NULL, 0, NULL },
7883 { NULL, NULL, NULL, 0, NULL }
7884 };
7885
7886
7887 static MENU misc_menu[] =
7888 {
7889 { (char *)"&About...", onAbout, NULL, 0, NULL },
7890 { (char *)"&Credits...", onCredits, NULL, 0, NULL },
7891 { (char *)"&Fullscreen", onFullscreenMenu, NULL, 0, NULL },
7892 { (char *)"&Video Mode...", onVidMode, NULL, 0, NULL },
7893 { (char *)"", NULL, NULL, 0, NULL },
7894 { (char *)"&Quest Info...", onQuest, NULL, 0, NULL },
7895 { (char *)"Quest &MIDI Info...", onMIDICredits, NULL, 0, NULL },
7896 { (char *)"Quest &Directory...", onQstPath, NULL, 0, NULL },
7897 { (char *)"", NULL, NULL, 0, NULL },
7898 { (char *)"Take &Snapshot\tF12", onSnapshot, NULL, 0, NULL },
7899 { (char *)"Sc&reen Saver...", onScreenSaver, NULL, 0, NULL },
7900 { (char *)"Save ZC Configuration", OnSaveZCConfig, NULL, 0, NULL },
7901 { (char *)"Show ZASM Debugger", onConsoleZASM, NULL, 0, NULL },
7902 { (char *)"Show ZScript Debugger", onConsoleZScript, NULL, 0, NULL },
7903 { (char *)"Clear Directory Cache", OnnClearQuestDir, NULL, 0, NULL },
7904 { (char *)"Modules", NULL, zcmodule_menu, 0, NULL },
7905 { (char *)"Replay", NULL, replay_menu, 0, NULL },
7906
7907 { NULL, NULL, NULL, 0, NULL }
7908 };
7909
7910 static MENU refill_menu[] =
7911 {
7912 { (char *)"&Life\t*, H", onRefillLife, NULL, 0, NULL },
7913 { (char *)"&Magic\t/, M", onRefillMagic, NULL, 0, NULL },
7914 { (char *)"&Bombs\tB", onCheatBombs, NULL, 0, NULL },
7915 { (char *)"&Rupees\tR", onCheatRupies, NULL, 0, NULL },
7916 { (char *)"&Arrows\tA", onCheatArrows, NULL, 0, NULL },
7917 { NULL, NULL, NULL, 0, NULL }
7918 };
7919
7920 static MENU show_menu[] =
7921 {
7922 { (char *)"Combos\t0", onShowLayer0, NULL, 0, NULL },
7923 { (char *)"Layer 1\t1", onShowLayer1, NULL, 0, NULL },
7924 { (char *)"Layer 2\t2", onShowLayer2, NULL, 0, NULL },
7925 { (char *)"Layer 3\t3", onShowLayer3, NULL, 0, NULL },
7926 { (char *)"Layer 4\t4", onShowLayer4, NULL, 0, NULL },
7927 { (char *)"Layer 5\t5", onShowLayer5, NULL, 0, NULL },
7928 { (char *)"Layer 6\t6", onShowLayer6, NULL, 0, NULL },
7929 { (char *)"Overhead Combos\tO", onShowLayerO, NULL, 0, NULL },
7930 { (char *)"Push Blocks\tP", onShowLayerP, NULL, 0, NULL },
7931 { (char *)"Freeform Combos\t7", onShowLayerF, NULL, 0, NULL },
7932 { (char *)"Sprites\t8", onShowLayerS, NULL, 0, NULL },
7933 { (char *)"", NULL, NULL, 0, NULL },
7934 { (char *)"Walkability\tW", onShowLayerW, NULL, 0, NULL },
7935 { (char *)"Current FFC Scripts\tF", onShowFFScripts, NULL, 0, NULL },
7936 { (char *)"Hitboxes\tC", onShowHitboxes, NULL, 0, NULL },
7937 { (char *)"Effects\tE", onShowLayerE, NULL, 0, NULL },
7938 { NULL, NULL, NULL, 0, NULL }
7939 };
7940
7941 static MENU cheat_menu[] =
7942 {
7943 { (char *)"S&et Cheat", onCheat, NULL, 0, NULL },
7944 { (char *)"", NULL, NULL, 0, NULL },
7945 { (char *)"Re&fill", NULL, refill_menu, 0, NULL },
7946 { (char *)"", NULL, NULL, 0, NULL },
7947 { (char *)"&Clock\tI", onClock, NULL, 0, NULL },
7948 { (char *)"Ma&x Bombs...", onMaxBombs, NULL, 0, NULL },
7949 { (char *)"&Heart Containers...", onHeartC, NULL, 0, NULL },
7950 { (char *)"&Magic Containers...", onMagicC, NULL, 0, NULL },
7951 { (char *)"", NULL, NULL, 0, NULL },
7952 { (char *)"&Player Data...", onCheatConsole, NULL, 0, NULL },
7953 { (char *)"", NULL, NULL, 0, NULL },
7954 { (char *)"Walk Through &Walls\tF11", onNoWalls, NULL, 0, NULL },
7955 { (char *)"Player Ignores Side&view\tV", onIgnoreSideview, NULL, 0, NULL },
7956 { (char *)"&Quick Movement\tQ", onGoFast, NULL, 0, NULL },
7957 { (char *)"&Kill All Enemies\tK", onKillCheat, NULL, 0, NULL },
7958 { (char *)"Show/Hide Layer", NULL, show_menu, 0, NULL },
7959 { (char *)"Toggle Light\tL", onLightSwitch, NULL, 0, NULL },
7960 { (char *)"&Goto Location...\tG", onGoTo, NULL, 0, NULL },
7961 { NULL, NULL, NULL, 0, NULL }
7962 };
7963
7964 static MENU fixes_menu[] =
7965 {
7966 { (char *)"Windows MIDI Patch", onMIDIPatch, NULL, 0, NULL },
7967 { NULL, NULL, NULL, 0, NULL }
7968 };
7969
7970 #if DEVLEVEL > 0
7971 int32_t devLogging();
7972 int32_t devDebug();
7973 int32_t devTimestmp();
7974 #if DEVLEVEL > 1
7975 int32_t setCheat();
7976 #endif //DEVLEVEL > 1
7977 enum
7978 {
7979 dv_log,
7980 // dv_dbg,
7981 dv_tmpstmp,
7982 #if DEVLEVEL > 1
7983 dv_nil,
7984 dv_setcheat,
7985 #endif //DEVLEVEL > 1
7986 dv_max
7987 };
7988 static MENU dev_menu[] =
7989 {
7990 { (char *)"&Force Error Log", devLogging, NULL, 0, NULL },
7991 // { (char *)"&Extra Debug Log", devDebug, NULL, 0, NULL },
7992 { (char *)"&Timestamp Log", devTimestmp, NULL, 0, NULL },
7993 #if DEVLEVEL > 1
7994 { (char *)"", NULL, NULL, 0, NULL },
7995 { (char *)"Set &Cheat", setCheat, NULL, 0, NULL },
7996 #endif //DEVLEVEL > 1
7997 { NULL, NULL, NULL, 0, NULL }
7998 };
7999 int32_t devLogging()
8000 {
8001 dev_logging = !dev_logging;
8002 dev_menu[dv_log].flags = dev_logging ? D_SELECTED : 0;
8003 return D_O_K;
8004 }
8005 // int32_t devDebug()
8006 // {
8007 // dev_debug = !dev_debug;
8008 // dev_menu[dv_dbg].flags = dev_debug ? D_SELECTED : 0;
8009 // return D_O_K;
8010 // }
8011 int32_t devTimestmp()
8012 {
8013 dev_timestmp = !dev_timestmp;
8014 dev_menu[dv_tmpstmp].flags = dev_timestmp ? D_SELECTED : 0;
8015 return D_O_K;
8016 }
8017 #if DEVLEVEL > 1
8018 int32_t setCheat()
8019 {
8020 cheat = (vbound(getnumber("Cheat Level",cheat), 0, 4));
8021 return D_O_K;
8022 }
8023 #endif //DEVLEVEL > 1
8024 #endif //DEVLEVEL > 0
8025
8026 MENU the_player_menu[] =
8027 {
8028 { (char *)"&Game", NULL, game_menu, 0, NULL },
8029 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8030 { (char *)"&Cheat", NULL, cheat_menu, 0, NULL },
8031 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8032 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8033 #if DEVLEVEL > 0
8034 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8035 #endif
8036 { NULL, NULL, NULL, 0, NULL }
8037 };
8038
8039 MENU the_player_menu2[] =
8040 {
8041 { (char *)"&Game", NULL, game_menu, 0, NULL },
8042 { (char *)"&Settings", NULL, settings_menu, 0, NULL },
8043 { (char *)"&Fixes", NULL, fixes_menu, 0, NULL },
8044 { (char *)"&ZC", NULL, misc_menu, 0, NULL },
8045 #if DEVLEVEL > 0
8046 { (char *)"&Dev", NULL, dev_menu, 0, NULL },
8047 #endif
8048 { NULL, NULL, NULL, 0, NULL }
8049 };
8050
8051 int32_t onMIDIPatch()
8052 {
8053 if(jwin_alert3(
8054 "Toggle Windows MIDI Fix",
8055 "This action will change whether ZC Player auto-restarts a MIDI at its",
8056 "last index if you move ZC Player out of focus, then back into focus.",
8057 "Proceed?",
8058 "&Yes",
8059 "&No",
8060 NULL,
8061 'y',
8062 'n',
8063 0,
8064 lfont) == 1)
8065 {
8066 midi_patch_fix = midi_patch_fix ? 0 : 1;
8067 zc_set_config("zeldadx","midi_patch_fix",midi_patch_fix);
8068 }
8069 fixes_menu[0].flags =(midi_patch_fix)?D_SELECTED:0;
8070 return D_O_K;
8071 }
8072
8073 int32_t onKeyboardEntry()
8074 {
8075 NameEntryMode=0;
8076 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8077 return D_O_K;
8078 }
8079
8080 int32_t onLetterGridEntry()
8081 {
8082 NameEntryMode=1;
8083 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8084 return D_O_K;
8085 }
8086
8087 int32_t onExtLetterGridEntry()
8088 {
8089 NameEntryMode=2;
8090 zc_set_config(cfg_sect,"name_entry_mode",NameEntryMode);
8091 return D_O_K;
8092 }
8093
8094 static BITMAP* oldscreen;
8095 int32_t onFullscreenMenu()
8096 {
8097 // super hacks
8098 screen = oldscreen;
8099 if (onFullscreen() == D_REDRAW)
8100 {
8101 oldscreen = screen;
8102 }
8103 screen = menu_bmp;
8104 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8105 return D_O_K;
8106 }
8107
8108 7 void fix_menu()
8109 {
8110
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(!debug_enabled)
8111 7 settings_menu[18].text = NULL;
8112 7 }
8113
8114 static DIALOG system_dlg[] =
8115 {
8116 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8117 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu, NULL, NULL },
8118 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8119 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8120 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8121 #ifndef ALLEGRO_MACOSX
8122 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8123 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8124 #else
8125 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8126 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8127 #endif
8128 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8129 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8130 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8131 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8132 };
8133
8134 static DIALOG system_dlg2[] =
8135 {
8136 /* (dialog proc) (x) (y) (w) (h) (fg) (bg) (key) (flags) (d1) (d2) (dp) */
8137 { jwin_menu_proc, 0, 0, 0, 0, 0, 0, 0, D_USER, 0, 0, (void *) the_player_menu2, NULL, NULL },
8138 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F1, 0, (void *) onVsync, NULL, NULL },
8139 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F2, 0, (void *) onShowFPS, NULL, NULL },
8140 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F6, 0, (void *) onTryQuitMenu, NULL, NULL },
8141 #ifndef ALLEGRO_MACOSX
8142 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F9, 0, (void *) onReset, NULL, NULL },
8143 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F10, 0, (void *) onExit, NULL, NULL },
8144 #else
8145 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F7, 0, (void *) onReset, NULL, NULL },
8146 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F8, 0, (void *) onExit, NULL, NULL },
8147 #endif
8148 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_F12, 0, (void *) onSnapshot, NULL, NULL },
8149 { d_keyboard_proc, 0, 0, 0, 0, 0, 0, 0, 0, KEY_TAB, 0, (void *) onDebug, NULL, NULL },
8150 { d_timer_proc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL },
8151 { NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL }
8152 };
8153
8154 void reset_snapshot_format_menu()
8155 {
8156 for(int32_t i=0; i<ssfmtMAX; ++i)
8157 {
8158 snapshot_format_menu[i].flags=0;
8159 }
8160 }
8161
8162 int32_t onSetSnapshotFormat()
8163 {
8164 switch(active_menu->text[1])
8165 {
8166 case 'B': //"&BMP"
8167 SnapshotFormat=0;
8168 break;
8169
8170 case 'G': //"&GIF"
8171 SnapshotFormat=1;
8172 break;
8173
8174 case 'J': //"&JPG"
8175 SnapshotFormat=2;
8176 break;
8177
8178 case 'P': //"&PNG"
8179 SnapshotFormat=3;
8180 break;
8181
8182 case 'C': //"PC&X"
8183 SnapshotFormat=4;
8184 break;
8185
8186 case 'T': //"&TGA"
8187 SnapshotFormat=5;
8188 break;
8189
8190 case 'L': //"&LBM"
8191 SnapshotFormat=6;
8192 break;
8193 }
8194 zc_set_config("zeldadx", "snapshot_format", SnapshotFormat);
8195
8196 snapshot_format_menu[SnapshotFormat].flags=D_SELECTED;
8197 return D_O_K;
8198 }
8199
8200
8201 8 void color_layer(RGB *src,RGB *dest,char r,char g,char b,char pos,int32_t from,int32_t to)
8202 {
8203 PALETTE tmp;
8204
8205
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 8 times.
2056 for(int32_t i=0; i<256; i++)
8206 {
8207 2048 tmp[i].r=r;
8208 2048 tmp[i].g=g;
8209 2048 tmp[i].b=b;
8210 2048 }
8211
8212 8 fade_interpolate(src,tmp,dest,pos,from,to);
8213 8 }
8214
8215 8 void system_pal()
8216 {
8217 8 is_sys_pal = true;
8218 static PALETTE pal;
8219 8 copy_pal((RGB*)datafile[PAL_GUI].dat, pal);
8220
8221 // set up the grayscale palette
8222
2/2
✓ Branch 0 taken 512 times.
✓ Branch 1 taken 8 times.
520 for(int32_t i=128; i<192; i++)
8223 {
8224 512 pal[i].r = i-128;
8225 512 pal[i].g = i-128;
8226 512 pal[i].b = i-128;
8227 512 }
8228 8 load_colorset(gui_colorset, pal);
8229
8230 8 color_layer(pal, pal, 24,16,16, 28, 128,191);
8231
8232
2/2
✓ Branch 0 taken 1024 times.
✓ Branch 1 taken 8 times.
1032 for(int32_t i=0; i<256; i+=2)
8233 {
8234 1024 int32_t v = (i>>3)+2;
8235 1024 int32_t c = (i>>3)+192;
8236 1024 pal[c] = _RGB(v,v,v+(v>>1));
8237 /*
8238 if(i<240)
8239 {
8240 _allegro_hline(tmp_scr,0,i,319,c);
8241 _allegro_hline(tmp_scr,0,i+1,319,c);
8242 }
8243 */
8244 1024 }
8245
8246 // draw the vertical screen gradient
8247
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 8 times.
1928 for(int32_t i=0; i<240; ++i)
8248 {
8249 1920 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8250 1920 }
8251
8252 /*
8253 palrstart= 10*63/255; palrend=166*63/255;
8254 palgstart= 36*63/255; palgend=202*63/255;
8255 palbstart=106*63/255; palbend=240*63/255;
8256 paldivs=32;
8257 for(int32_t i=0; i<paldivs; i++)
8258 {
8259 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8260 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8261 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8262 }
8263 */
8264 8 BITMAP *panorama = create_bitmap_ex(8,256,224);
8265 int32_t ts_height, ts_start;
8266
8267
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8268 {
8269 clear_to_color(panorama,0);
8270 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8271 ts_height=224-passive_subscreen_height;
8272 ts_start=28;
8273 }
8274 else
8275 {
8276 8 blit(framebuf,panorama,0,0,0,0,256,224);
8277 8 ts_height=224;
8278 8 ts_start=0;
8279 }
8280
8281 // gray scale the current frame
8282
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 8 times.
1800 for(int32_t y=0; y<ts_height; y++)
8283 {
8284
2/2
✓ Branch 0 taken 458752 times.
✓ Branch 1 taken 1792 times.
460544 for(int32_t x=0; x<256; x++)
8285 {
8286 458752 int32_t c = panorama->line[y+ts_start][x];
8287
2/2
✓ Branch 0 taken 458271 times.
✓ Branch 1 taken 481 times.
458752 int32_t gray = zc_min((RAMpal[c].r*42 + RAMpal[c].g*75 + RAMpal[c].b*14) >> 7, 63);
8288 458752 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8289 458752 }
8290 1792 }
8291
8292 8 destroy_bitmap(panorama);
8293
8294 // display everything
8295 8 vsync();
8296 8 hw_palette = &pal;
8297 8 update_hw_pal = true;
8298
8299 // sys_pal = pal;
8300 8 memcpy(sys_pal,pal,sizeof(pal));
8301 8 }
8302
8303 void system_pal2()
8304 {
8305 is_sys_pal = true;
8306 static PALETTE RAMpal2;
8307 copy_pal((RGB*)datafile[PAL_GUI].dat, RAMpal2);
8308
8309 /* Windows 2000 colors
8310 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8311 RAMpal2[dvc(2)] = _RGB( 66*63/255, 65*63/255, 66*63/255);
8312 RAMpal2[dvc(3)] = _RGB(132*63/255, 130*63/255, 132*63/255);
8313 RAMpal2[dvc(4)] = _RGB(212*63/255, 208*63/255, 200*63/255);
8314 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8315 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8316 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8317 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8318
8319 byte palrstart= 10*63/255, palrend=166*63/255,
8320 palgstart= 36*63/255, palgend=202*63/255,
8321 palbstart=106*63/255, palbend=240*63/255,
8322 paldivs=7;
8323 for(int32_t i=0; i<paldivs; i++)
8324 {
8325 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8326 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8327 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8328 }
8329 */
8330
8331 /* Windows 98 colors
8332 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8333 RAMpal2[dvc(2)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8334 RAMpal2[dvc(3)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8335 RAMpal2[dvc(4)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8336 RAMpal2[dvc(5)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8337 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8338 RAMpal2[dvc(7)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8339 RAMpal2[dvc(8)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8340
8341 byte palrstart= 0*63/255, palrend=166*63/255,
8342 palgstart= 0*63/255, palgend=202*63/255,
8343 palbstart=128*63/255, palbend=240*63/255,
8344 paldivs=7;
8345 for(int32_t i=0; i<paldivs; i++)
8346 {
8347 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8348 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8349 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8350 }
8351 */
8352
8353 /* Windows 99 colors
8354 RAMpal2[dvc(1)] = _RGB( 0*63/255, 0*63/255, 0*63/255);
8355 RAMpal2[dvc(2)] = _RGB( 64*63/255, 64*63/255, 64*63/255);
8356 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8357 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8358 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8359 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8360 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8361 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8362 RAMpal2[dvc(9)] = _RGB( 0*63/255, 0*63/255, 80*63/255);
8363
8364 byte palrstart= 0*63/255, palrend=166*63/255,
8365 palgstart= 0*63/255, palgend=202*63/255,
8366
8367 palbstart=128*63/255, palbend=240*63/255,
8368 paldivs=6;
8369 for(int32_t i=0; i<paldivs; i++)
8370 {
8371 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8372 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8373 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8374 }
8375 */
8376
8377
8378
8379 RAMpal2[dvc(1)] = _RGB(0*63/255, 0*63/255, 0*63/255);
8380 RAMpal2[dvc(2)] = _RGB(64*63/255, 64*63/255, 64*63/255);
8381 RAMpal2[dvc(3)] = _RGB(128*63/255, 128*63/255, 128*63/255);
8382 RAMpal2[dvc(4)] = _RGB(192*63/255, 192*63/255, 192*63/255);
8383 RAMpal2[dvc(5)] = _RGB(223*63/255, 223*63/255, 223*63/255);
8384 RAMpal2[dvc(6)] = _RGB(255*63/255, 255*63/255, 255*63/255);
8385 RAMpal2[dvc(7)] = _RGB(255*63/255, 255*63/255, 225*63/255);
8386 RAMpal2[dvc(8)] = _RGB(255*63/255, 225*63/255, 160*63/255);
8387 RAMpal2[dvc(9)] = _RGB(0*63/255, 0*63/255, 80*63/255);
8388
8389 byte palrstart= 0*63/255, palrend=166*63/255,
8390 palgstart= 0*63/255, palgend=202*63/255,
8391 palbstart=128*63/255, palbend=240*63/255,
8392 paldivs=6;
8393
8394 for(int32_t i=0; i<paldivs; i++)
8395 {
8396 RAMpal2[dvc(15-paldivs+1)+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8397 RAMpal2[dvc(15-paldivs+1)+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8398 RAMpal2[dvc(15-paldivs+1)+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8399 }
8400
8401 gui_bg_color=jwin_pal[jcBOX];
8402 gui_fg_color=jwin_pal[jcBOXFG];
8403
8404 jwin_set_colors(jwin_pal);
8405
8406
8407 // set up the new palette
8408 for(int32_t i=128; i<192; i++)
8409 {
8410 RAMpal2[i].r = i-128;
8411 RAMpal2[i].g = i-128;
8412 RAMpal2[i].b = i-128;
8413 }
8414
8415 /*
8416 for(int32_t i=0; i<64; i++)
8417 {
8418 RAMpal2[128+i] = _RGB(i,i,i)1));
8419 }
8420 */
8421
8422 /*
8423
8424 pal[vc(1)] = _RGB(0x00,0x00,0x14);
8425 pal[vc(4)] = _RGB(0x36,0x36,0x36);
8426 pal[vc(6)] = _RGB(0x10,0x10,0x10);
8427 pal[vc(7)] = _RGB(0x20,0x20,0x20);
8428 pal[vc(9)] = _RGB(0x20,0x20,0x24);
8429 pal[vc(11)] = _RGB(0x30,0x30,0x30);
8430 pal[vc(14)] = _RGB(0x3F,0x38,0x28);
8431
8432 gui_fg_color=vc(14);
8433 gui_bg_color=vc(1);
8434
8435 jwin_set_colors(jwin_pal);
8436 */
8437
8438 // color_layer(RAMpal2, RAMpal2, 24,16,16, 28, 128,191);
8439
8440 // set up the colors for the vertical screen gradient
8441 for(int32_t i=0; i<256; i+=2)
8442 {
8443 int32_t v = (i>>3)+2;
8444 int32_t c = (i>>3)+192;
8445 RAMpal2[c] = _RGB(v,v,v+(v>>1));
8446
8447 /*
8448 if(i<240)
8449 {
8450 _allegro_hline(tmp_scr,0,i,319,c);
8451 _allegro_hline(tmp_scr,0,i+1,319,c);
8452 }
8453 */
8454 }
8455
8456 // hw_palette = &RAMpal;
8457 // update_hw_pal = true;
8458
8459 for(int32_t i=0; i<240; ++i)
8460 {
8461 _allegro_hline(tmp_scr,0,i,319,192+(i*31/239));
8462 }
8463
8464 /*
8465 byte palrstart= 10*63/255, palrend=166*63/255,
8466 palgstart= 36*63/255, palgend=202*63/255,
8467 palbstart=106*63/255, palbend=240*63/255,
8468 paldivs=32;
8469 for(int32_t i=0; i<paldivs; i++)
8470 {
8471 pal[223-paldivs+1+i].r = palrstart+((palrend-palrstart)*i/(paldivs-1));
8472 pal[223-paldivs+1+i].g = palgstart+((palgend-palgstart)*i/(paldivs-1));
8473 pal[223-paldivs+1+i].b = palbstart+((palbend-palbstart)*i/(paldivs-1));
8474 }
8475 */
8476 BITMAP *panorama = create_bitmap_ex(8,256,224);
8477 int32_t ts_height, ts_start;
8478
8479 if(tmpscr->flags3&fNOSUBSCR && !(tmpscr->flags3&fNOSUBSCROFFSET))
8480 {
8481 clear_to_color(panorama,0);
8482 blit(framebuf,panorama,0,playing_field_offset,0,28,256,224-passive_subscreen_height);
8483 ts_height=224-passive_subscreen_height;
8484 ts_start=28;
8485 }
8486 else
8487 {
8488 blit(framebuf,panorama,0,0,0,0,256,224);
8489 ts_height=224;
8490 ts_start=0;
8491 }
8492
8493 // gray scale the current frame
8494 for(int32_t y=0; y<ts_height; y++)
8495 {
8496 for(int32_t x=0; x<256; x++)
8497 {
8498 int32_t c = panorama->line[y+ts_start][x];
8499 int32_t gray = zc_min((RAMpal2[c].r*42 + RAMpal2[c].g*75 + RAMpal2[c].b*14) >> 7, 63);
8500 tmp_scr->line[y+8+ts_start][x+32] = gray+128;
8501 }
8502 }
8503
8504 destroy_bitmap(panorama);
8505
8506 // display everything
8507 vsync();
8508 hw_palette = &RAMpal2;
8509 update_hw_pal = true;
8510
8511 blit(tmp_scr,screen,0,0,scrx,scry,320,240);
8512
8513 // sys_pal = pal;
8514 memcpy(sys_pal,RAMpal2,sizeof(RAMpal2));
8515 }
8516
8517 static uint32_t entered_sys_pal = 0;
8518 1 void enter_sys_pal()
8519 {
8520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(is_sys_pal)
8521 {
8522 if(entered_sys_pal)
8523 ++entered_sys_pal;
8524 return;
8525 }
8526 1 system_pal();
8527 1 ++entered_sys_pal;
8528 1 }
8529 1 void exit_sys_pal()
8530 {
8531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(entered_sys_pal)
8532 {
8533
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!--entered_sys_pal)
8534 {
8535 1 game_pal();
8536 1 }
8537 1 }
8538 1 }
8539
8540 1 void switch_out_callback()
8541 {
8542
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if (pause_in_background)
8543 {
8544 callback_switchin = 3;
8545 return;
8546 }
8547
8548 #ifdef _WIN32
8549 if(midi_patch_fix==0 || currmidi==-1)
8550 return;
8551
8552
8553 paused_midi_pos = midi_pos;
8554 zc_stop_midi();
8555 midi_paused=true;
8556 midi_suspended = midissuspHALTED;
8557 #endif
8558 1 }
8559
8560 void switch_in_callback()
8561 {
8562 zc_update_builtin_font();
8563
8564 if(pause_in_background)
8565 {
8566 return;
8567 }
8568
8569 #ifdef _WIN32
8570 if(midi_patch_fix==0 || currmidi==-1)
8571 return;
8572
8573 else
8574 {
8575 callback_switchin = 1;
8576 midi_suspended = midissuspRESUME;
8577 }
8578 #endif
8579 }
8580
8581 26 void game_pal()
8582 {
8583 26 is_sys_pal = false;
8584 26 entered_sys_pal = 0;
8585 26 clear_to_color(screen,BLACK);
8586 26 hw_palette = &RAMpal;
8587 26 update_hw_pal = true;
8588 26 }
8589
8590 static char bar_str[] = "";
8591
8592 1 void music_pause()
8593 {
8594 //al_pause_duh(tmplayer);
8595 1 zcmusic_pause(zcmusic, ZCM_PAUSE);
8596 1 zc_midi_pause();
8597 1 midi_paused=true;
8598 1 }
8599
8600 void music_resume()
8601 {
8602 //al_resume_duh(tmplayer);
8603 zcmusic_pause(zcmusic, ZCM_RESUME);
8604 zc_midi_resume();
8605 midi_paused=false;
8606 }
8607
8608 190 void music_stop()
8609 {
8610 //al_stop_duh(tmplayer);
8611 //unload_duh(tmusic);
8612 //tmusic=NULL;
8613 //tmplayer=NULL;
8614 190 zcmusic_stop(zcmusic);
8615 190 zcmusic_unload_file(zcmusic);
8616 190 zc_stop_midi();
8617 190 midi_paused=false;
8618 190 currmidi=-1;
8619 190 }
8620
8621 void System()
8622 {
8623 mouse_down=gui_mouse_b();
8624 music_pause();
8625 pause_all_sfx();
8626 MenuOpen = true;
8627 system_pal();
8628 // FONT *oldfont=font;
8629 // font=tfont;
8630
8631 misc_menu[2].flags =(isFullScreen()==1)?D_SELECTED:0;
8632 misc_menu[3].flags =(isFullScreen()==1)?D_DISABLED:0;
8633
8634 game_menu[2].flags = getsaveslot() > -1 ? 0 : D_DISABLED;
8635 #if DEVLEVEL > 1
8636 dev_menu[dv_setcheat].flags = Playing ? 0 : D_DISABLED;
8637 #endif
8638 game_menu[3].flags =
8639 misc_menu[5].flags = Playing ? 0 : D_DISABLED;
8640 misc_menu[7].flags = !Playing ? 0 : D_DISABLED;
8641 fixes_menu[0].flags = (midi_patch_fix)?D_SELECTED:0;
8642 clear_keybuf();
8643 show_mouse(screen);
8644
8645 DIALOG_PLAYER *p;
8646
8647 clear_bitmap(menu_bmp);
8648 oldscreen = screen;
8649 screen = menu_bmp;
8650
8651 if(!Playing || (!zcheats.flags && !get_debug() && DEVLEVEL < 2 && !zqtesting_mode))
8652 {
8653 p = init_dialog(system_dlg2,-1);
8654 }
8655 else
8656 {
8657 p = init_dialog(system_dlg,-1);
8658 }
8659
8660 // drop the menu on startup if menu button pressed
8661 if(joybtn(Mbtn)||zc_getrawkey(KEY_ESC))
8662 simulate_keypress(KEY_G << 8);
8663
8664 do
8665 {
8666 if(close_button_quit)
8667 {
8668 close_button_quit = false;
8669 f_Quit(qEXIT);
8670 if(Quit) break;
8671 }
8672 rest(17);
8673
8674 if(mouse_down && !gui_mouse_b())
8675 mouse_down=0;
8676
8677 title_menu[0].flags = (title_version==0) ? D_SELECTED : 0;
8678 title_menu[1].flags = (title_version==1) ? D_SELECTED : 0;
8679 title_menu[2].flags = (title_version==2) ? D_SELECTED : 0;
8680
8681 settings_menu[1].flags = replay_is_replaying() ? D_DISABLED : 0;
8682 settings_menu[5].flags = Throttlefps?D_SELECTED:0;
8683 settings_menu[6].flags = ShowFPS?D_SELECTED:0;
8684 settings_menu[7].flags = TransLayers?D_SELECTED:0;
8685 settings_menu[8].flags = NESquit?D_SELECTED:0;
8686 settings_menu[9].flags = ClickToFreeze?D_SELECTED:0;
8687 settings_menu[10].flags = SaveDragResize?D_SELECTED:0;
8688 settings_menu[11].flags = DragAspect?D_SELECTED:0;
8689 settings_menu[12].flags = SaveWinPos?D_SELECTED:0;
8690 settings_menu[13].flags = volkeys?D_SELECTED:0;
8691 //Epilepsy Prevention
8692 settings_menu[16].flags = (epilepsyFlashReduction) ? D_SELECTED : 0;
8693
8694 name_entry_mode_menu[0].flags = (NameEntryMode==0)?D_SELECTED:0;
8695 name_entry_mode_menu[1].flags = (NameEntryMode==1)?D_SELECTED:0;
8696 name_entry_mode_menu[2].flags = (NameEntryMode==2)?D_SELECTED:0;
8697
8698 misc_menu[12].flags =(zasm_debugger)?D_SELECTED:0;
8699 misc_menu[13].flags =(zscript_debugger)?D_SELECTED:0;
8700
8701 the_player_menu[2].flags = replay_is_replaying() ? D_DISABLED : 0;
8702 cheat_menu[0].flags = 0;
8703 refill_menu[4].flags = get_bit(quest_rules, qr_TRUEARROWS) ? 0 : D_DISABLED;
8704 cheat_menu[1].text = (cheat >= 1) || get_debug() ? bar_str : NULL;
8705 cheat_menu[3].text = (cheat >= 2) || get_debug() ? bar_str : NULL;
8706 cheat_menu[8].text = (cheat >= 3) || get_debug() ? bar_str : NULL;
8707 cheat_menu[10].text = (cheat >= 4) || get_debug() ? bar_str : NULL;
8708 cheat_menu[4].flags = getClock() ? D_SELECTED : 0;
8709 cheat_menu[11].flags = toogam ? D_SELECTED : 0;
8710 cheat_menu[12].flags = ignoreSideview ? D_SELECTED : 0;
8711 cheat_menu[13].flags = gofast ? D_SELECTED : 0;
8712
8713 show_menu[0].flags = show_layer_0 ? D_SELECTED : 0;
8714 show_menu[1].flags = show_layer_1 ? D_SELECTED : 0;
8715 show_menu[2].flags = show_layer_2 ? D_SELECTED : 0;
8716 show_menu[3].flags = show_layer_3 ? D_SELECTED : 0;
8717 show_menu[4].flags = show_layer_4 ? D_SELECTED : 0;
8718 show_menu[5].flags = show_layer_5 ? D_SELECTED : 0;
8719 show_menu[6].flags = show_layer_6 ? D_SELECTED : 0;
8720 show_menu[7].flags = show_layer_over ? D_SELECTED : 0;
8721 show_menu[8].flags = show_layer_push ? D_SELECTED : 0;
8722 show_menu[9].flags = show_sprites ? D_SELECTED : 0;
8723 show_menu[10].flags = show_ffcs ? D_SELECTED : 0;
8724 show_menu[12].flags = show_walkflags ? D_SELECTED : 0;
8725 show_menu[13].flags = show_ff_scripts ? D_SELECTED : 0;
8726 show_menu[14].flags = show_hitboxes ? D_SELECTED : 0;
8727 show_menu[15].flags = show_effectflags ? D_SELECTED : 0;
8728
8729 settings_menu[14].flags = heart_beep ? D_SELECTED : 0;
8730 settings_menu[15].flags = use_save_indicator ? D_SELECTED : 0;
8731
8732 replay_menu[0].text = zc_get_config("zeldadx", "replay_new_saves", false) ?
8733 (char *)"Disable recording new saves" :
8734 (char *)"Enable recording new saves";
8735 replay_menu[1].flags = replay_is_active() ? 0 : D_DISABLED;
8736 replay_menu[1].text = replay_get_mode() == ReplayMode::Record ?
8737 (char *)"Stop recording" :
8738 (char *)"Stop replaying";
8739 replay_menu[5].flags = replay_get_mode() == ReplayMode::Record ? 0 : D_DISABLED;
8740
8741 reset_snapshot_format_menu();
8742 snapshot_format_menu[SnapshotFormat].flags = D_SELECTED;
8743
8744 if(debug_enabled)
8745 {
8746 settings_menu[19].flags = get_debug() ? D_SELECTED : 0;
8747 }
8748
8749 if(gui_mouse_b() && !mouse_down)
8750 break;
8751
8752 // press menu to drop the menu
8753 if(rMbtn())
8754 simulate_keypress(KEY_G << 8);
8755
8756 if(input_idle(true) > after_time())
8757 // run Screeen Saver
8758 {
8759 // Screen saver enabled for now.
8760 clear_keybuf();
8761 scare_mouse();
8762 Matrix(ss_speed, ss_density, 0);
8763 system_pal();
8764 unscare_mouse();
8765 broadcast_dialog_message(MSG_DRAW, 0);
8766 }
8767
8768 update_hw_screen();
8769 }
8770 while(update_dialog(p));
8771
8772 screen = oldscreen;
8773
8774 // font=oldfont;
8775 mouse_down=gui_mouse_b();
8776 shutdown_dialog(p);
8777 show_mouse(NULL);
8778 MenuOpen = false;
8779 if(Quit)
8780 {
8781 kill_sfx();
8782 music_stop();
8783 update_hw_screen();
8784 }
8785 else
8786 {
8787 game_pal();
8788 music_resume();
8789 resume_all_sfx();
8790
8791 if(rc)
8792 ringcolor(false);
8793 }
8794
8795 eat_buttons();
8796
8797 rc=false;
8798 clear_keybuf();
8799 // text_mode(0);
8800 }
8801
8802 7 void fix_dialogs()
8803 {
8804 7 jwin_center_dialog(about_dlg);
8805 7 jwin_center_dialog(gamepad_dlg);
8806 7 jwin_center_dialog(credits_dlg);
8807 7 jwin_center_dialog(gamemode_dlg);
8808 7 jwin_center_dialog(getnum_dlg);
8809 7 jwin_center_dialog(goto_dlg);
8810 7 jwin_center_dialog(keyboard_control_dlg);
8811 7 jwin_center_dialog(midi_dlg);
8812 7 jwin_center_dialog(quest_dlg);
8813 7 jwin_center_dialog(scrsaver_dlg);
8814 7 jwin_center_dialog(sound_dlg);
8815 7 jwin_center_dialog(triforce_dlg);
8816
8817 // digi_dp[1] += scrx;
8818 // digi_dp[2] += scry;
8819 // midi_dp[1] += scrx;
8820 // midi_dp[2] += scry;
8821 // pan_dp[1] += scrx;
8822 // pan_dp[2] += scry;
8823 // emus_dp[1] += scrx;
8824 // emus_dp[2] += scry;
8825 // buf_dp[1] += scrx;
8826 // buf_dp[2] += scry;
8827 // sfx_dp[1] += scrx;
8828 // sfx_dp[2] += scry;
8829 7 }
8830
8831 /*****************************/
8832 /**** Custom Sound System ****/
8833 /*****************************/
8834
8835 87 INLINE int32_t mixvol(int32_t v1,int32_t v2)
8836 {
8837
3/4
✓ Branch 0 taken 77 times.
✓ Branch 1 taken 10 times.
✓ Branch 2 taken 87 times.
✗ Branch 3 not taken.
87 return (zc_min(v1,255)*zc_min(v2,255)) >> 8;
8838 }
8839
8840 // Run an NSF, or a MIDI if the NSF is missing somehow.
8841 4 bool try_zcmusic(char *filename, int32_t track, int32_t midi)
8842 {
8843 4 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8844
8845 // Found it
8846
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(newzcmusic!=NULL)
8847 {
8848 4 zcmusic_stop(zcmusic);
8849 4 zcmusic_unload_file(zcmusic);
8850 4 zc_stop_midi();
8851
8852 4 zcmusic=newzcmusic;
8853 4 zcmusic_play(zcmusic, emusic_volume);
8854
8855
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if(track>0)
8856 4 zcmusic_change_track(zcmusic,track);
8857
8858 4 return true;
8859 }
8860
8861 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8862 else if(midi>-1000)
8863 jukebox(midi);
8864
8865 return false;
8866 4 }
8867
8868 bool try_zcmusic_ex(char *filename, int32_t track, int32_t midi)
8869 {
8870 ZCMUSIC *newzcmusic = zcmusic_load_for_quest(filename, qstpath);
8871 // Found it
8872 if(newzcmusic!=NULL)
8873 {
8874 zcmusic_stop(zcmusic);
8875 zcmusic_unload_file(zcmusic);
8876 zc_stop_midi();
8877
8878 zcmusic=newzcmusic;
8879 zcmusic_play(zcmusic, emusic_volume);
8880
8881 if(track>0)
8882 zcmusic_change_track(zcmusic,track);
8883
8884 return true;
8885 }
8886
8887 // Not found, play MIDI - unless this was called by a script (yay, magic numbers)
8888 else if(midi>-1000)
8889 jukebox(midi);
8890
8891 return false;
8892 }
8893
8894 int32_t get_zcmusicpos()
8895 {
8896 int32_t debugtracething = zcmusic_get_curpos(zcmusic);
8897 return debugtracething;
8898 return 0;
8899 }
8900
8901 void set_zcmusicpos(int32_t position)
8902 {
8903 zcmusic_set_curpos(zcmusic, position);
8904 }
8905
8906 void set_zcmusicspeed(int32_t speed)
8907 {
8908 int32_t newspeed = vbound(speed, 0, 10000);
8909 zcmusic_set_speed(zcmusic, newspeed);
8910 }
8911
8912 40 void jukebox(int32_t index,int32_t loop)
8913 {
8914 40 music_stop();
8915
8916
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(index<0) index=MAXMIDIS-1;
8917
8918
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(index>=MAXMIDIS) index=0;
8919
8920 40 music_stop();
8921
8922 // Allegro's DIGMID driver (the one normally used on on Linux) gets
8923 // stuck notes when a song stops. This fixes it.
8924
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(strcmp(midi_driver->name, "DIGMID")==0)
8925 zc_set_volume(0, 0);
8926
8927 40 zc_set_volume(-1, mixvol(tunes[index].volume,midi_volume>>1));
8928 40 zc_play_midi((MIDI*)tunes[index].data,loop);
8929
8930
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 9 times.
40 if(tunes[index].start>0)
8931 9 zc_midi_seek(tunes[index].start);
8932
8933 40 midi_loop_start = tunes[index].loop_start;
8934 40 midi_loop_end = tunes[index].loop_end;
8935
8936 40 currmidi=index;
8937 40 master_volume(digi_volume,midi_volume);
8938 40 midi_paused=false;
8939 40 }
8940
8941 242 void jukebox(int32_t index)
8942 {
8943
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(index<0) index=MAXMIDIS-1;
8944
8945
1/2
✓ Branch 0 taken 242 times.
✗ Branch 1 not taken.
242 if(index>=MAXMIDIS) index=0;
8946
8947 // do nothing if it's already playing
8948
3/4
✓ Branch 0 taken 202 times.
✓ Branch 1 taken 40 times.
✓ Branch 2 taken 202 times.
✗ Branch 3 not taken.
242 if(index==currmidi && midi_pos>=0)
8949 {
8950 202 midi_paused=false;
8951 202 return;
8952 }
8953
8954 40 jukebox(index,tunes[index].loop);
8955 242 }
8956
8957 279 void play_DmapMusic()
8958 {
8959 static char tfile[2048];
8960 static int32_t ttrack=0;
8961 279 bool domidi=false;
8962
8963
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 243 times.
279 if(DMaps[currdmap].tmusic[0]!=0)
8964 {
8965
3/4
✓ Branch 0 taken 26 times.
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 26 times.
62 if(zcmusic==NULL ||
8966
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 strcmp(zcmusic->filename,DMaps[currdmap].tmusic)!=0 ||
8967
1/2
✓ Branch 0 taken 26 times.
✗ Branch 1 not taken.
26 (zcmusic->type==ZCMF_GME && zcmusic->track != DMaps[currdmap].tmusictrack))
8968 {
8969
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 if(zcmusic != NULL)
8970 {
8971 zcmusic_stop(zcmusic);
8972 zcmusic_unload_file(zcmusic);
8973 zcmusic = NULL;
8974 }
8975
8976 10 zcmusic = zcmusic_load_for_quest(DMaps[currdmap].tmusic, qstpath);
8977
8978
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if(zcmusic!=NULL)
8979 {
8980 10 zc_stop_midi();
8981 10 strcpy(tfile,DMaps[currdmap].tmusic);
8982 10 zcmusic_play(zcmusic, emusic_volume);
8983 10 int32_t temptracks=0;
8984 10 temptracks=zcmusic_get_tracks(zcmusic);
8985
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10 times.
10 temptracks=(temptracks<2)?1:temptracks;
8986 10 ttrack = vbound(DMaps[currdmap].tmusictrack,0,temptracks-1);
8987 10 zcmusic_change_track(zcmusic,ttrack);
8988 10 }
8989 else
8990 {
8991 tfile[0] = 0;
8992 domidi=true;
8993 }
8994 10 }
8995 36 }
8996 else
8997 {
8998 243 domidi=true;
8999 }
9000
9001
2/2
✓ Branch 0 taken 36 times.
✓ Branch 1 taken 243 times.
279 if(domidi)
9002 {
9003 243 int32_t m=DMaps[currdmap].midi;
9004
9005
3/4
✓ Branch 0 taken 154 times.
✓ Branch 1 taken 80 times.
✓ Branch 2 taken 9 times.
✗ Branch 3 not taken.
243 switch(m)
9006 {
9007 case 1:
9008 80 jukebox(ZC_MIDI_OVERWORLD);
9009 80 break;
9010
9011 case 2:
9012 9 jukebox(ZC_MIDI_DUNGEON);
9013 9 break;
9014
9015 case 3:
9016 jukebox(ZC_MIDI_LEVEL9);
9017 break;
9018
9019 default:
9020
3/4
✓ Branch 0 taken 147 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 147 times.
154 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9021 147 jukebox(m+MIDIOFFSET_DMAP);
9022 else
9023 7 music_stop();
9024 154 }
9025 243 }
9026 279 }
9027
9028 279 void playLevelMusic()
9029 {
9030 279 int32_t m=tmpscr->screen_midi;
9031
9032
1/6
✓ Branch 0 taken 279 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
279 switch(m)
9033 {
9034 case -2:
9035 music_stop();
9036 break;
9037
9038 case -1:
9039 279 play_DmapMusic();
9040 279 break;
9041
9042 case 1:
9043 jukebox(ZC_MIDI_OVERWORLD);
9044 break;
9045
9046 case 2:
9047 jukebox(ZC_MIDI_DUNGEON);
9048 break;
9049
9050 case 3:
9051 jukebox(ZC_MIDI_LEVEL9);
9052 break;
9053
9054 default:
9055 if(m>=4 && m<4+MAXCUSTOMMIDIS)
9056 jukebox(m+MIDIOFFSET_MAPSCR);
9057 else
9058 music_stop();
9059 }
9060 279 }
9061
9062 47 void master_volume(int32_t dv,int32_t mv)
9063 {
9064
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
47 if(dv>=0) digi_volume=zc_max(zc_min(dv,255),0);
9065
9066
4/8
✗ Branch 0 not taken.
✓ Branch 1 taken 47 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 47 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 47 times.
✗ Branch 7 not taken.
47 if(mv>=0) midi_volume=zc_max(zc_min(mv,255),0);
9067
9068
5/6
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 9 times.
✓ Branch 2 taken 47 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 38 times.
✓ Branch 5 taken 9 times.
47 int32_t i = zc_min(zc_max(currmidi,0),MAXMIDIS-1);
9069 47 zc_set_volume(digi_volume,mixvol(tunes[i].volume,midi_volume));
9070 47 }
9071
9072 /*****************/
9073 /***** SFX *****/
9074 /*****************/
9075
9076 // array of voices, one for each sfx sample in the data file
9077 // 0+ = voice #
9078 // -1 = voice not allocated
9079 7 void Z_init_sound()
9080 {
9081
2/2
✓ Branch 0 taken 1792 times.
✓ Branch 1 taken 7 times.
1799 for(int32_t i=0; i<WAV_COUNT; i++)
9082 1792 sfx_voice[i]=-1;
9083
9084
2/2
✓ Branch 0 taken 49 times.
✓ Branch 1 taken 7 times.
56 for(int32_t i=0; i<ZC_MIDI_COUNT; i++)
9085 49 tunes[i].data = (MIDI*)mididata[i].dat;
9086
9087
2/2
✓ Branch 0 taken 1764 times.
✓ Branch 1 taken 7 times.
1771 for(int32_t j=0; j<MAXCUSTOMMIDIS; j++)
9088 1764 tunes[ZC_MIDI_COUNT+j].data=NULL;
9089
9090 7 master_volume(digi_volume,midi_volume);
9091 7 }
9092
9093 // returns number of voices currently allocated
9094 int32_t sfx_count()
9095 {
9096 int32_t c=0;
9097
9098 for(int32_t i=0; i<WAV_COUNT; i++)
9099 if(sfx_voice[i]!=-1)
9100 ++c;
9101
9102 return c;
9103 }
9104
9105 // clean up finished samples
9106 203804 void sfx_cleanup()
9107 {
9108
2/2
✓ Branch 0 taken 52173824 times.
✓ Branch 1 taken 203804 times.
52377628 for(int32_t i=0; i<WAV_COUNT; i++)
9109
4/4
✓ Branch 0 taken 761619 times.
✓ Branch 1 taken 51412205 times.
✓ Branch 2 taken 760176 times.
✓ Branch 3 taken 1443 times.
52175267 if(sfx_voice[i]!=-1 && voice_get_position(sfx_voice[i])<0)
9110 {
9111 1443 deallocate_voice(sfx_voice[i]);
9112 1443 sfx_voice[i]=-1;
9113 1443 }
9114 203804 }
9115
9116 // allocates a voice for the sample "wav_index" (index into zelda.dat)
9117 // if a voice is already allocated (and/or playing), then it just returns true
9118 // Returns true: voice is allocated
9119 // false: unsuccessful
9120 34391 bool sfx_init(int32_t index)
9121 {
9122 // check index
9123
3/4
✓ Branch 0 taken 32747 times.
✓ Branch 1 taken 1644 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 32747 times.
34391 if(index<=0 || index>=WAV_COUNT)
9124 1644 return false;
9125
9126
2/2
✓ Branch 0 taken 30569 times.
✓ Branch 1 taken 2178 times.
32747 if(sfx_voice[index]==-1)
9127 {
9128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2178 times.
2178 if(sfxdat)
9129 {
9130 if(index<Z35)
9131 {
9132 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[index].dat);
9133 }
9134 else
9135 {
9136 sfx_voice[index]=allocate_voice((SAMPLE*)sfxdata[Z35].dat);
9137 }
9138 }
9139 else
9140 {
9141 2178 sfx_voice[index]=allocate_voice(&customsfxdata[index]);
9142 }
9143
9144 2178 voice_set_volume(sfx_voice[index], sfx_volume);
9145 2178 }
9146
9147 32747 return sfx_voice[index] != -1;
9148 34391 }
9149
9150 // plays an sfx sample
9151 24951 void sfx(int32_t index,int32_t pan,bool loop, bool restart)
9152 {
9153
2/2
✓ Branch 0 taken 23864 times.
✓ Branch 1 taken 1087 times.
24951 if(!sfx_init(index))
9154 1087 return;
9155
9156 23864 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9157 23864 voice_set_pan(sfx_voice[index],pan);
9158
9159 23864 int32_t pos = voice_get_position(sfx_voice[index]);
9160
9161
2/2
✓ Branch 0 taken 11185 times.
✓ Branch 1 taken 12679 times.
23864 if(restart) voice_set_position(sfx_voice[index],0);
9162
9163
2/2
✓ Branch 0 taken 13236 times.
✓ Branch 1 taken 10628 times.
23864 if(pos<=0)
9164 13236 voice_start(sfx_voice[index]);
9165 24951 }
9166
9167 // true if sfx is allocated
9168 bool sfx_allocated(int32_t index)
9169 {
9170 return (index>0 && index<WAV_COUNT && sfx_voice[index]!=-1);
9171 }
9172
9173 // start it (in loop mode) if it's not already playing,
9174 // otherwise adjust it to play in loop mode -DD
9175 9440 void cont_sfx(int32_t index)
9176 {
9177
2/2
✓ Branch 0 taken 557 times.
✓ Branch 1 taken 8883 times.
9440 if(!sfx_init(index))
9178 {
9179 557 return;
9180 }
9181
9182
2/2
✓ Branch 0 taken 324 times.
✓ Branch 1 taken 8559 times.
8883 if(voice_get_position(sfx_voice[index])<=0)
9183 {
9184 324 voice_set_position(sfx_voice[index],0);
9185 324 voice_set_playmode(sfx_voice[index],PLAYMODE_LOOP);
9186 324 voice_start(sfx_voice[index]);
9187 324 }
9188 else
9189 {
9190 8559 adjust_sfx(index, 128, true);
9191 }
9192 9440 }
9193
9194 // adjust parameters while playing
9195 8689 void adjust_sfx(int32_t index,int32_t pan,bool loop)
9196 {
9197
5/6
✓ Branch 0 taken 8596 times.
✓ Branch 1 taken 93 times.
✓ Branch 2 taken 8596 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 8568 times.
✓ Branch 5 taken 28 times.
8689 if(index<=0 || index>=WAV_COUNT || sfx_voice[index]==-1)
9198 121 return;
9199
9200 8568 voice_set_playmode(sfx_voice[index],loop?PLAYMODE_LOOP:PLAYMODE_PLAY);
9201 8568 voice_set_pan(sfx_voice[index],pan);
9202 8689 }
9203
9204 // pauses a voice
9205 18 void pause_sfx(int32_t index)
9206 {
9207
3/6
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
18 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9208 voice_stop(sfx_voice[index]);
9209 18 }
9210
9211 // resumes a voice
9212 8 void resume_sfx(int32_t index)
9213 {
9214
3/6
✓ Branch 0 taken 8 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 8 times.
8 if(index>0 && index<WAV_COUNT && sfx_voice[index]!=-1)
9215 voice_start(sfx_voice[index]);
9216 8 }
9217
9218 // pauses all active voices
9219 1 void pause_all_sfx()
9220 {
9221
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 1 times.
257 for(int32_t i=0; i<WAV_COUNT; i++)
9222
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 2 times.
258 if(sfx_voice[i]!=-1)
9223 2 voice_stop(sfx_voice[i]);
9224 1 }
9225
9226 // resumes all paused voices
9227 void resume_all_sfx()
9228 {
9229 for(int32_t i=0; i<WAV_COUNT; i++)
9230 if(sfx_voice[i]!=-1)
9231 voice_start(sfx_voice[i]);
9232 }
9233
9234 // stops an sfx and deallocates the voice
9235 170274 void stop_sfx(int32_t index)
9236 {
9237
3/4
✓ Branch 0 taken 169859 times.
✓ Branch 1 taken 415 times.
✓ Branch 2 taken 169859 times.
✗ Branch 3 not taken.
170274 if(index<=0 || index>=WAV_COUNT)
9238 415 return;
9239
9240
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 169283 times.
169859 if(sfx_voice[index]!=-1)
9241 {
9242 576 deallocate_voice(sfx_voice[index]);
9243 576 sfx_voice[index]=-1;
9244 576 }
9245 170274 }
9246
9247 // Stops SFX played by Hero's item of the given family
9248 4172 void stop_item_sfx(int32_t family)
9249 {
9250 4172 int32_t id=current_item_id(family);
9251
9252
2/2
✓ Branch 0 taken 4162 times.
✓ Branch 1 taken 10 times.
4172 if(id<0)
9253 4162 return;
9254
9255 10 stop_sfx(itemsbuf[id].usesound);
9256 4172 }
9257
9258 73 void kill_sfx()
9259 {
9260
2/2
✓ Branch 0 taken 18688 times.
✓ Branch 1 taken 73 times.
18761 for(int32_t i=0; i<WAV_COUNT; i++)
9261
2/2
✓ Branch 0 taken 18537 times.
✓ Branch 1 taken 151 times.
18839 if(sfx_voice[i]!=-1)
9262 {
9263 151 deallocate_voice(sfx_voice[i]);
9264 151 sfx_voice[i]=-1;
9265 151 }
9266 73 }
9267
9268 23181 int32_t pan(int32_t x)
9269 {
9270
1/4
✓ Branch 0 taken 23181 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
23181 switch(pan_style)
9271 {
9272 case 0:
9273 return 128;
9274
9275 case 1:
9276 23181 return vbound((x>>1)+68,0,255);
9277
9278 case 2:
9279 return vbound(((x*3)>>2)+36,0,255);
9280 }
9281
9282 return vbound(x,0,255);
9283 23181 }
9284
9285 /*******************************/
9286 /******* Input Handlers ********/
9287 /*******************************/
9288
9289 389938 bool joybtn(int32_t b)
9290 {
9291
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 389938 times.
389938 if(b == 0)
9292 return false;
9293
9294 389938 return joy[joystick_index].button[b-1].b !=0;
9295 389938 }
9296
9297 const char* joybtn_name(int32_t b)
9298 {
9299 if(b == 0)
9300 return "";
9301
9302 return joy[joystick_index].button[b-1].name;
9303 }
9304
9305 int32_t next_press_key()
9306 {
9307 return readkey()>>8;
9308 }
9309
9310 int32_t next_press_btn()
9311 {
9312 clear_keybuf();
9313 /*bool b[joy[joystick_index].num_buttons+1];
9314
9315 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9316 b[i]=joybtn(i);*/
9317
9318 //first, we need to wait until they're pressing no buttons
9319 for(;;)
9320 {
9321 if(keypressed())
9322 {
9323 switch(readkey()>>8)
9324 {
9325 case KEY_ESC:
9326 return -1;
9327
9328 case KEY_SPACE:
9329 return 0;
9330 }
9331 }
9332
9333 poll_joystick();
9334 bool done = true;
9335
9336 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9337 {
9338 if(joybtn(i)) done = false;
9339 }
9340
9341 if(done) break;
9342 rest(1);
9343 }
9344
9345 //now, we need to wait for them to press any button
9346 for(;;)
9347 {
9348 if(keypressed())
9349 {
9350 switch(readkey()>>8)
9351 {
9352 case KEY_ESC:
9353 return -1;
9354
9355 case KEY_SPACE:
9356 return 0;
9357 }
9358 }
9359
9360 poll_joystick();
9361
9362 for(int32_t i=1; i<=joy[joystick_index].num_buttons; i++)
9363 {
9364 if(joybtn(i)) return i;
9365 }
9366 rest(1);
9367 }
9368 }
9369
9370 static bool rButton(bool(proc)(),bool &flag)
9371 {
9372 if(!proc())
9373 {
9374 flag=false;
9375 }
9376 else if(!flag)
9377 {
9378 flag=true;
9379 return true;
9380 }
9381
9382 return false;
9383 }
9384
9385 4289496 static bool rButton(bool &btn, bool &flag)
9386 {
9387
2/2
✓ Branch 0 taken 164244 times.
✓ Branch 1 taken 4125252 times.
4289496 if(!btn)
9388 {
9389 4125252 flag=false;
9390 4125252 }
9391
2/2
✓ Branch 0 taken 8717 times.
✓ Branch 1 taken 155527 times.
164244 else if(!flag)
9392 {
9393 8717 flag=true;
9394 8717 return true;
9395 }
9396
9397 4280779 return false;
9398 4289496 }
9399 619 static bool rButtonPeek(bool btn, bool flag)
9400 {
9401
2/2
✓ Branch 0 taken 583 times.
✓ Branch 1 taken 36 times.
619 if(!btn)
9402 {
9403 583 return false;
9404 }
9405
2/2
✓ Branch 0 taken 9 times.
✓ Branch 1 taken 27 times.
36 else if(!flag)
9406 {
9407 9 return true;
9408 }
9409
9410 27 return false;
9411 619 }
9412
9413 // Updated only by keyboard/gamepad.
9414 // If in replay mode, this is set directly by the replay system.
9415 // This should never be read from directly - use control_state instead.
9416 bool raw_control_state[ZC_CONTROL_STATES]=
9417 {
9418 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9419 };
9420
9421 // Every call to load_control_state (pretty much every frame) resets this to be equal to raw_control_state.
9422 // This state can drift from raw_control_state if button states are "eaten" or overriden by a script. But that only
9423 // lasts until the next call to load_control_state.
9424 bool control_state[ZC_CONTROL_STATES]=
9425 {
9426 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9427 };
9428
9429 bool disable_control[ZC_CONTROL_STATES]=
9430 {
9431 false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false
9432 };
9433
9434 bool drunk_toggle_state[11]=
9435 {
9436 false, false, false, false, false, false, false, false, false, false, false
9437 };
9438
9439 bool disabledKeys[127]=
9440 {
9441 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9442 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9443 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9444 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9445 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9446 false,false,false,false,false,false,false
9447 };
9448
9449 bool KeyInput[127]=
9450 {
9451 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9452 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9453 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9454 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9455 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9456 false,false,false,false,false,false,false
9457 };
9458
9459 bool KeyPress[127]=
9460 {
9461 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9462 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9463 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9464 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9465 false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,
9466 false,false,false,false,false,false,false
9467 };
9468
9469 bool key_current_frame[127];
9470 bool key_previous_frame[127];
9471
9472 static bool key_system[127];
9473 static bool key_system_previous[127];
9474 static bool key_system_press[127];
9475
9476 bool button_press[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9477 bool button_hold[ZC_CONTROL_STATES] = {false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false};
9478
9479 #define STICK_1_X joy[joystick_index].stick[js_stick_1_x_stick].axis[js_stick_1_x_axis]
9480 #define STICK_1_Y joy[joystick_index].stick[js_stick_1_y_stick].axis[js_stick_1_y_axis]
9481 #define STICK_2_X joy[joystick_index].stick[js_stick_2_x_stick].axis[js_stick_2_x_axis]
9482 #define STICK_2_Y joy[joystick_index].stick[js_stick_2_y_stick].axis[js_stick_2_y_axis]
9483 #define STICK_PRECISION 56 //define your own sensitivity
9484
9485 172652 void load_control_state()
9486 {
9487
1/2
✓ Branch 0 taken 172652 times.
✗ Branch 1 not taken.
172652 if (!replay_is_replaying())
9488 {
9489 raw_control_state[0]=zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset < -STICK_PRECISION : joybtn(DUbtn));
9490 raw_control_state[1]=zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn));
9491 raw_control_state[2]=zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn));
9492 raw_control_state[3]=zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn));
9493 raw_control_state[4]=zc_getrawkey(Akey, true)||joybtn(Abtn);
9494 raw_control_state[5]=zc_getrawkey(Bkey, true)||joybtn(Bbtn);
9495 raw_control_state[6]=zc_getrawkey(Skey, true)||joybtn(Sbtn);
9496 raw_control_state[7]=zc_getrawkey(Lkey, true)||joybtn(Lbtn);
9497 raw_control_state[8]=zc_getrawkey(Rkey, true)||joybtn(Rbtn);
9498 raw_control_state[9]=zc_getrawkey(Pkey, true)||joybtn(Pbtn);
9499 raw_control_state[10]=zc_getrawkey(Exkey1, true)||joybtn(Exbtn1);
9500 raw_control_state[11]=zc_getrawkey(Exkey2, true)||joybtn(Exbtn2);
9501 raw_control_state[12]=zc_getrawkey(Exkey3, true)||joybtn(Exbtn3);
9502 raw_control_state[13]=zc_getrawkey(Exkey4, true)||joybtn(Exbtn4);
9503
9504 if(num_joysticks != 0)
9505 {
9506 raw_control_state[14] = STICK_2_Y.pos - js_stick_2_y_offset < -STICK_PRECISION;
9507 raw_control_state[15] = STICK_2_Y.pos - js_stick_2_y_offset > STICK_PRECISION;
9508 raw_control_state[16] = STICK_2_X.pos - js_stick_2_x_offset < -STICK_PRECISION;
9509 raw_control_state[17] = STICK_2_X.pos - js_stick_2_x_offset > STICK_PRECISION;
9510 // zprint2("Detected %d joysticks... %d%d%d%d\n", num_joysticks, raw_control_state[14]?1:0, raw_control_state[15]?1:0, raw_control_state[16]?1:0, raw_control_state[17]?1:0);
9511 }
9512 else
9513 {
9514 raw_control_state[14] = false;
9515 raw_control_state[15] = false;
9516 raw_control_state[16] = false;
9517 raw_control_state[17] = false;
9518 // zprint2("Detected 0 joysticks... clearing inputaxis values.\n");
9519 }
9520 }
9521
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 172651 times.
172652 if (replay_is_active())
9522 {
9523
2/2
✓ Branch 0 taken 134629 times.
✓ Branch 1 taken 38022 times.
172651 if (replay_get_version() < 3)
9524 134629 replay_poll();
9525
3/4
✓ Branch 0 taken 38022 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 9443 times.
✓ Branch 3 taken 28579 times.
38022 else if (replay_is_replaying() && replay_get_version() < 6)
9526 28579 replay_peek_input();
9527 172651 }
9528
9529 // Some test replay files were made before a serious input bug was fixed, so instead
9530 // of re-doing them or tossing them out, just check for that zplay version.
9531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 172650 times.
172652 bool botched_input = replay_is_replaying() && replay_get_version() == 1;
9532
2/2
✓ Branch 0 taken 172650 times.
✓ Branch 1 taken 3107700 times.
3280350 for (int i = 0; i < ZC_CONTROL_STATES; i++)
9533 {
9534 3107700 control_state[i] = raw_control_state[i];
9535
4/4
✓ Branch 0 taken 913500 times.
✓ Branch 1 taken 2194200 times.
✓ Branch 2 taken 45148 times.
✓ Branch 3 taken 868352 times.
3107700 if(!botched_input && !control_state[i])
9536 868352 down_control_states[i] = false;
9537 3107700 }
9538
9539 172650 button_press[0]=rButton(control_state[0],button_hold[0]);
9540 172650 button_press[1]=rButton(control_state[1],button_hold[1]);
9541 172650 button_press[2]=rButton(control_state[2],button_hold[2]);
9542 172650 button_press[3]=rButton(control_state[3],button_hold[3]);
9543 172650 button_press[4]=rButton(control_state[4],button_hold[4]);
9544 172650 button_press[5]=rButton(control_state[5],button_hold[5]);
9545 172650 button_press[6]=rButton(control_state[6],button_hold[6]);
9546 172650 button_press[7]=rButton(control_state[7],button_hold[7]);
9547 172650 button_press[8]=rButton(control_state[8],button_hold[8]);
9548 172650 button_press[9]=rButton(control_state[9],button_hold[9]);
9549 172650 button_press[10]=rButton(control_state[10],button_hold[10]);
9550 172650 button_press[11]=rButton(control_state[11],button_hold[11]);
9551 172650 button_press[12]=rButton(control_state[12],button_hold[12]);
9552 172650 button_press[13]=rButton(control_state[13],button_hold[13]);
9553 172650 button_press[14]=rButton(control_state[14],button_hold[14]);
9554 172650 button_press[15]=rButton(control_state[15],button_hold[15]);
9555 172650 button_press[16]=rButton(control_state[16],button_hold[16]);
9556 172650 button_press[17]=rButton(control_state[17],button_hold[17]);
9557 172650 }
9558
9559 // Returns true if any game key is pressed. This is needed because keypressed()
9560 // doesn't detect modifier keys and control_state[] can be modified by scripts.
9561 795728 bool zc_key_pressed()
9562 //may also need to use zc_getrawkey
9563 {
9564
7/10
✓ Branch 0 taken 633023 times.
✓ Branch 1 taken 162705 times.
✓ Branch 2 taken 162705 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 162705 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 136962 times.
✓ Branch 7 taken 136962 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 38297 times.
834025 if((zc_getrawkey(DUkey, true)||(analog_movement ? STICK_1_Y.d1 || STICK_1_Y.pos - js_stick_1_y_offset< -STICK_PRECISION : joybtn(DUbtn))) ||
9565
4/6
✓ Branch 0 taken 136962 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 136962 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 99926 times.
✓ Branch 5 taken 99926 times.
136962 (zc_getrawkey(DDkey, true)||(analog_movement ? STICK_1_Y.d2 || STICK_1_Y.pos - js_stick_1_y_offset > STICK_PRECISION : joybtn(DDbtn))) ||
9566
4/6
✓ Branch 0 taken 99926 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 99926 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 58594 times.
✓ Branch 5 taken 58594 times.
99926 (zc_getrawkey(DLkey, true)||(analog_movement ? STICK_1_X.d1 || STICK_1_X.pos - js_stick_1_x_offset < -STICK_PRECISION : joybtn(DLbtn))) ||
9567
4/6
✓ Branch 0 taken 58594 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 58594 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 43939 times.
✓ Branch 5 taken 43939 times.
58594 (zc_getrawkey(DRkey, true)||(analog_movement ? STICK_1_X.d2 || STICK_1_X.pos - js_stick_1_x_offset > STICK_PRECISION : joybtn(DRbtn))) ||
9568
1/2
✓ Branch 0 taken 43939 times.
✗ Branch 1 not taken.
43939 (zc_getrawkey(Akey, true)||joybtn(Abtn)) ||
9569
3/4
✓ Branch 0 taken 39439 times.
✓ Branch 1 taken 4500 times.
✓ Branch 2 taken 39439 times.
✗ Branch 3 not taken.
43939 (zc_getrawkey(Bkey, true)||joybtn(Bbtn)) ||
9570
3/4
✓ Branch 0 taken 38415 times.
✓ Branch 1 taken 1024 times.
✓ Branch 2 taken 38415 times.
✗ Branch 3 not taken.
39439 (zc_getrawkey(Skey, true)||joybtn(Sbtn)) ||
9571
3/4
✓ Branch 0 taken 38363 times.
✓ Branch 1 taken 52 times.
✓ Branch 2 taken 38363 times.
✗ Branch 3 not taken.
38415 (zc_getrawkey(Lkey, true)||joybtn(Lbtn)) ||
9572
3/4
✓ Branch 0 taken 38297 times.
✓ Branch 1 taken 66 times.
✓ Branch 2 taken 38297 times.
✗ Branch 3 not taken.
38363 (zc_getrawkey(Rkey, true)||joybtn(Rbtn)) ||
9573
2/4
✓ Branch 0 taken 38297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38297 times.
✗ Branch 3 not taken.
38297 (zc_getrawkey(Pkey, true)||joybtn(Pbtn)) ||
9574
2/4
✓ Branch 0 taken 38297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38297 times.
✗ Branch 3 not taken.
38297 (zc_getrawkey(Exkey1, true)||joybtn(Exbtn1)) ||
9575
2/4
✓ Branch 0 taken 38297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38297 times.
✗ Branch 3 not taken.
38297 (zc_getrawkey(Exkey2, true)||joybtn(Exbtn2)) ||
9576
2/4
✓ Branch 0 taken 38297 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 38297 times.
✗ Branch 3 not taken.
38297 (zc_getrawkey(Exkey3, true)||joybtn(Exbtn3)) ||
9577
1/2
✓ Branch 0 taken 38297 times.
✗ Branch 1 not taken.
38297 (zc_getrawkey(Exkey4, true)||joybtn(Exbtn4))) // Skipping joystick axes
9578 1436273 return true;
9579
9580 38297 return false;
9581 208524 }
9582
9583 3534431 bool getInput(int32_t btn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9584 {
9585 3534431 bool ret = false, drunkstate = false;
9586 3534431 bool* flag = &down_control_states[btn];
9587
2/7
✓ Branch 0 taken 3325648 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 208783 times.
3534431 switch(btn)
9588 {
9589 case btnF12:
9590 ret = zc_getkey(KEY_F12, ignoreDisable);
9591 eatEntirely = false;
9592 break;
9593 case btnF11:
9594 ret = zc_getkey(KEY_F11, ignoreDisable);
9595 eatEntirely = false;
9596 break;
9597 case btnF5:
9598 ret = zc_getkey(KEY_F5, ignoreDisable);
9599 eatEntirely = false;
9600 break;
9601 case btnQ:
9602 ret = zc_getkey(KEY_Q, ignoreDisable);
9603 eatEntirely = false;
9604 break;
9605 case btnI:
9606 ret = zc_getkey(KEY_I, ignoreDisable);
9607 eatEntirely = false;
9608 break;
9609 case btnM:
9610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208783 times.
208783 if(FFCore.kb_typing_mode) return false;
9611 208783 ret = zc_getrawkey(KEY_ESC, ignoreDisable);
9612 208783 eatEntirely = false;
9613 208783 break;
9614 default: //control_state[] index
9615
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3325648 times.
3325648 if(FFCore.kb_typing_mode) return false;
9616
5/6
✓ Branch 0 taken 3320602 times.
✓ Branch 1 taken 5046 times.
✓ Branch 2 taken 237289 times.
✓ Branch 3 taken 3083313 times.
✓ Branch 4 taken 237289 times.
✗ Branch 5 not taken.
3325648 if(!ignoreDisable && get_bit(quest_rules, qr_FIXDRUNKINPUTS) && disable_control[btn]) drunk = false;
9617
2/2
✓ Branch 0 taken 173373 times.
✓ Branch 1 taken 3152275 times.
3325648 else if(btn<11) drunkstate = drunk_toggle_state[btn];
9618
4/4
✓ Branch 0 taken 2953381 times.
✓ Branch 1 taken 372267 times.
✓ Branch 2 taken 174 times.
✓ Branch 3 taken 372093 times.
3697915 ret = control_state[btn] && (ignoreDisable || !disable_control[btn]);
9619 3325648 }
9620
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3534431 times.
3534431 assert(flag);
9621
2/2
✓ Branch 0 taken 2352016 times.
✓ Branch 1 taken 1182415 times.
3534431 if(press)
9622 {
9623
2/2
✓ Branch 0 taken 619 times.
✓ Branch 1 taken 1181796 times.
1182415 if(peek)
9624 619 ret = rButtonPeek(ret, *flag);
9625 1181796 else ret = rButton(ret, *flag);
9626 1182415 }
9627
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3534431 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3534431 if(eatEntirely && ret) control_state[btn] = false;
9628
3/4
✓ Branch 0 taken 2727990 times.
✓ Branch 1 taken 806441 times.
✓ Branch 2 taken 2727990 times.
✗ Branch 3 not taken.
3534431 if(drunk && drunkstate) ret = !ret;
9629 3534431 return ret;
9630 3534431 }
9631
9632 8056 byte getIntBtnInput(byte intbtn, bool press, bool drunk, bool ignoreDisable, bool eatEntirely, bool peek)
9633 {
9634 8056 byte ret = 0;
9635
2/2
✓ Branch 0 taken 7437 times.
✓ Branch 1 taken 619 times.
8056 if(intbtn & INT_BTN_A) ret |= getInput(btnA, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_A : 0;
9636
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_B) ret |= getInput(btnB, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_B : 0;
9637
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_L) ret |= getInput(btnL, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_L : 0;
9638
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_R) ret |= getInput(btnR, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_R : 0;
9639
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX1) ret |= getInput(btnEx1, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX1 : 0;
9640
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX2) ret |= getInput(btnEx2, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX2 : 0;
9641
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX3) ret |= getInput(btnEx3, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX3 : 0;
9642
1/2
✓ Branch 0 taken 8056 times.
✗ Branch 1 not taken.
8056 if(intbtn & INT_BTN_EX4) ret |= getInput(btnEx4, press, drunk, ignoreDisable, eatEntirely, peek) ? INT_BTN_EX4 : 0;
9643 8056 return ret; //No early return, to make sure all button presses are eaten that should be! -Em
9644 }
9645
9646 byte checkIntBtnVal(byte intbtn, byte vals)
9647 {
9648 return intbtn&vals;
9649 }
9650
9651 34362 bool Up()
9652 {
9653 34362 return getInput(btnUp);
9654 }
9655 1142 bool Down()
9656 {
9657 1142 return getInput(btnDown);
9658 }
9659 2676 bool Left()
9660 {
9661 2676 return getInput(btnLeft);
9662 }
9663 3513 bool Right()
9664 {
9665 3513 return getInput(btnRight);
9666 }
9667 913 bool cAbtn()
9668 {
9669 913 return getInput(btnA);
9670 }
9671 17629 bool cBbtn()
9672 {
9673 17629 return getInput(btnB);
9674 }
9675 bool cSbtn()
9676 {
9677 return getInput(btnS);
9678 }
9679 bool cLbtn()
9680 {
9681 return getInput(btnL);
9682 }
9683 bool cRbtn()
9684 {
9685 return getInput(btnR);
9686 }
9687 bool cPbtn()
9688 {
9689 return getInput(btnP);
9690 }
9691 bool cEx1btn()
9692 {
9693 return getInput(btnEx1);
9694 }
9695 bool cEx2btn()
9696 {
9697 return getInput(btnEx2);
9698 }
9699 bool cEx3btn()
9700 {
9701 return getInput(btnEx3);
9702 }
9703 bool cEx4btn()
9704 {
9705 return getInput(btnEx4);
9706 }
9707 bool AxisUp()
9708 {
9709 return getInput(btnAxisUp);
9710 }
9711 bool AxisDown()
9712 {
9713 return getInput(btnAxisDown);
9714 }
9715 bool AxisLeft()
9716 {
9717 return getInput(btnAxisLeft);
9718 }
9719 bool AxisRight()
9720 {
9721 return getInput(btnAxisRight);
9722 }
9723
9724 bool cMbtn()
9725 {
9726 return getInput(btnM);
9727 }
9728 bool cF12()
9729 {
9730 return getInput(btnF12);
9731 }
9732 bool cF11()
9733 {
9734 return getInput(btnF11);
9735 }
9736 bool cF5()
9737 {
9738 return getInput(btnF5);
9739 }
9740 bool cQ()
9741 {
9742 return getInput(btnQ);
9743 }
9744 bool cI()
9745 {
9746 return getInput(btnI);
9747 }
9748
9749 241 bool rUp()
9750 {
9751 241 return getInput(btnUp, true);
9752 }
9753 234 bool rDown()
9754 {
9755 234 return getInput(btnDown, true);
9756 }
9757 233 bool rLeft()
9758 {
9759 233 return getInput(btnLeft, true);
9760 }
9761 233 bool rRight()
9762 {
9763 233 return getInput(btnRight, true);
9764 }
9765 16 bool rAbtn()
9766 {
9767 16 return getInput(btnA, true);
9768 }
9769 257 bool rBbtn()
9770 {
9771 257 return getInput(btnB, true);
9772 }
9773 172370 bool rSbtn()
9774 {
9775 172370 return getInput(btnS, true);
9776 }
9777 208524 bool rMbtn()
9778 {
9779 208524 return getInput(btnM, true);
9780 }
9781 233 bool rLbtn()
9782 {
9783 233 return getInput(btnL, true);
9784 }
9785 233 bool rRbtn()
9786 {
9787 233 return getInput(btnR, true);
9788 }
9789 172132 bool rPbtn()
9790 {
9791 172132 return getInput(btnP, true);
9792 }
9793 bool rEx1btn()
9794 {
9795 return getInput(btnEx1, true);
9796 }
9797 bool rEx2btn()
9798 {
9799 return getInput(btnEx2, true);
9800 }
9801 233 bool rEx3btn()
9802 {
9803 233 return getInput(btnEx3, true);
9804 }
9805 233 bool rEx4btn()
9806 {
9807 233 return getInput(btnEx4, true);
9808 }
9809 bool rAxisUp()
9810 {
9811 return getInput(btnAxisUp, true);
9812 }
9813 bool rAxisDown()
9814 {
9815 return getInput(btnAxisDown, true);
9816 }
9817 bool rAxisLeft()
9818 {
9819 return getInput(btnAxisLeft, true);
9820 }
9821 bool rAxisRight()
9822 {
9823 return getInput(btnAxisRight, true);
9824 }
9825
9826 bool rF11()
9827 {
9828 return getInput(btnF11, true);
9829 }
9830 bool rQ()
9831 {
9832 return getInput(btnQ, true);
9833 }
9834 bool rI()
9835 {
9836 return getInput(btnI, true);
9837 }
9838
9839 457993 bool DrunkUp()
9840 {
9841 457993 return getInput(btnUp, false, true);
9842 }
9843 423747 bool DrunkDown()
9844 {
9845 423747 return getInput(btnDown, false, true);
9846 }
9847 272060 bool DrunkLeft()
9848 {
9849 272060 return getInput(btnLeft, false, true);
9850 }
9851 238114 bool DrunkRight()
9852 {
9853 238114 return getInput(btnRight, false, true);
9854 }
9855 197671 bool DrunkcAbtn()
9856 {
9857 197671 return getInput(btnA, false, true);
9858 }
9859 172207 bool DrunkcBbtn()
9860 {
9861 172207 return getInput(btnB, false, true);
9862 }
9863 172130 bool DrunkcEx1btn()
9864 {
9865 172130 return getInput(btnEx1, false, true);
9866 }
9867 172130 bool DrunkcEx2btn()
9868 {
9869 172130 return getInput(btnEx2, false, true);
9870 }
9871 bool DrunkcSbtn()
9872 {
9873 return getInput(btnS, false, true);
9874 }
9875 bool DrunkcMbtn()
9876 {
9877 return getInput(btnM, false, true);
9878 }
9879 bool DrunkcLbtn()
9880 {
9881 return getInput(btnL, false, true);
9882 }
9883 bool DrunkcRbtn()
9884 {
9885 return getInput(btnR, false, true);
9886 }
9887 bool DrunkcPbtn()
9888 {
9889 return getInput(btnP, false, true);
9890 }
9891
9892 bool DrunkrUp()
9893 {
9894 return getInput(btnUp, true, true);
9895 }
9896 bool DrunkrDown()
9897 {
9898 return getInput(btnDown, true, true);
9899 }
9900 bool DrunkrLeft()
9901 {
9902 return getInput(btnLeft, true, true);
9903 }
9904 bool DrunkrRight()
9905 {
9906 return getInput(btnRight, true, true);
9907 }
9908 138241 bool DrunkrAbtn()
9909 {
9910 138241 return getInput(btnA, true, true);
9911 }
9912 138837 bool DrunkrBbtn()
9913 {
9914 138837 return getInput(btnB, true, true);
9915 }
9916 bool DrunkrEx1btn()
9917 {
9918 return getInput(btnEx1, true, true);
9919 }
9920 bool DrunkrEx2btn()
9921 {
9922 return getInput(btnEx2, true, true);
9923 }
9924 bool DrunkrEx3btn()
9925 {
9926 return getInput(btnEx3, true, true);
9927 }
9928 bool DrunkrEx4btn()
9929 {
9930 return getInput(btnEx4, true, true);
9931 }
9932 bool DrunkrSbtn()
9933 {
9934 return getInput(btnS, true, true);
9935 }
9936 bool DrunkrMbtn()
9937 {
9938 return getInput(btnM, true, true);
9939 }
9940 172132 bool DrunkrLbtn()
9941 {
9942 172132 return getInput(btnL, true, true);
9943 }
9944 172109 bool DrunkrRbtn()
9945 {
9946 172109 return getInput(btnR, true, true);
9947 }
9948 bool DrunkrPbtn()
9949 {
9950 return getInput(btnP, true, true);
9951 }
9952
9953 259 void eat_buttons()
9954 {
9955 259 getInput(btnA, true, false, true);
9956 259 getInput(btnB, true, false, true);
9957 259 getInput(btnS, true, false, true);
9958 259 getInput(btnM, true, false, true);
9959 259 getInput(btnL, true, false, true);
9960 259 getInput(btnR, true, false, true);
9961 259 getInput(btnP, true, false, true);
9962 259 getInput(btnEx1, true, false, true);
9963 259 getInput(btnEx2, true, false, true);
9964 259 getInput(btnEx3, true, false, true);
9965 259 getInput(btnEx4, true, false, true);
9966 259 }
9967
9968 // Is true for the _first frame_ of a key press.
9969 // But! it is possible that a script manually sets the value of KeyPress,
9970 // in which case it will be restored to the "true" value based on `key_current_frame`
9971 // and `key_previous_frame` on the next frame.
9972 1 bool zc_readkey(int32_t k, bool ignoreDisable)
9973 {
9974
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 if(ignoreDisable) return KeyPress[k];
9975
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1 times.
1 switch(k)
9976 {
9977 case KEY_F7:
9978 case KEY_F8:
9979 case KEY_F9:
9980 return KeyPress[k];
9981
9982 default:
9983
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 return KeyPress[k] && !disabledKeys[k];
9984 }
9985 1 }
9986
9987 // Is true for _every frame_ a key is held down.
9988 // But! it is possible that a script manually sets the value of KeyInput,
9989 // in which case it will be restored to the "true" value based on `key_current_frame`
9990 // on the next frame.
9991 bool zc_getkey(int32_t k, bool ignoreDisable)
9992 {
9993 if(ignoreDisable) return KeyInput[k];
9994 switch(k)
9995 {
9996 case KEY_F7:
9997 case KEY_F8:
9998 case KEY_F9:
9999 return KeyInput[k];
10000
10001 default:
10002 return KeyInput[k] && !disabledKeys[k];
10003 }
10004 }
10005
10006 // Reads (and then clears) the current frame key state directly.
10007 // Scripts can also modify `key_current_frame`.
10008 111803 bool zc_readrawkey(int32_t k, bool ignoreDisable)
10009 {
10010
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 111803 times.
111803 if(zc_getrawkey(k, ignoreDisable))
10011 {
10012 _key[k]=key[k]=key_current_frame[k]=0;
10013 return true;
10014 }
10015 111803 _key[k]=key[k]=key_current_frame[k]=0;
10016 111803 return false;
10017 111803 }
10018
10019 // Reads the current frame key state directly.
10020 // Scripts can also modify `key_current_frame`.
10021 1338938 bool zc_getrawkey(int32_t k, bool ignoreDisable)
10022 {
10023
2/2
✓ Branch 0 taken 1018612 times.
✓ Branch 1 taken 320326 times.
1338938 if(ignoreDisable) return key_current_frame[k];
10024
2/2
✓ Branch 0 taken 111800 times.
✓ Branch 1 taken 208526 times.
320326 switch(k)
10025 {
10026 case KEY_F7:
10027 case KEY_F8:
10028 case KEY_F9:
10029 111800 return key_current_frame[k];
10030
10031 default:
10032
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 208526 times.
208526 return key_current_frame[k] && !disabledKeys[k];
10033 }
10034 1338938 }
10035
10036 // Only used for a handful of keys, like tilde and Function keys.
10037 // This state is never read within the game.
10038 // It exists so that all keyboard input still functions during replay,
10039 // without inadvertently doing things like toggling throttling if the player
10040 // presses ~
10041 203804 bool zc_get_system_key(int32_t k)
10042 {
10043 203804 return key_system[k];
10044 }
10045
10046 // True for the _first_ frame of a key press.
10047 2293764 bool zc_read_system_key(int32_t k)
10048 {
10049 2293764 return key_system_press[k];
10050 }
10051
10052 26482548 bool is_system_key(int32_t k)
10053 {
10054
2/2
✓ Branch 0 taken 24605832 times.
✓ Branch 1 taken 1876716 times.
26482548 switch (k)
10055 {
10056 case KEY_BACKQUOTE:
10057 case KEY_CLOSEBRACE:
10058 case KEY_END:
10059 case KEY_HOME:
10060 case KEY_OPENBRACE:
10061 case KEY_PGDN:
10062 case KEY_PGUP:
10063 case KEY_TAB:
10064 case KEY_TILDE:
10065 1876716 return true;
10066 }
10067 24605832 return is_Fkey(k);
10068 26482548 }
10069
10070 208524 void update_system_keys()
10071 {
10072 208524 poll_keyboard();
10073
2/2
✓ Branch 0 taken 26482548 times.
✓ Branch 1 taken 208524 times.
26691072 for (int32_t q = 0; q < 127; ++q)
10074 {
10075
2/2
✓ Branch 0 taken 4379004 times.
✓ Branch 1 taken 22103544 times.
26482548 if (!is_system_key(q))
10076 22103544 continue;
10077
10078 4379004 key_system[q] = key[q];
10079
1/2
✓ Branch 0 taken 4379004 times.
✗ Branch 1 not taken.
4379004 key_system_press[q] = key_system[q] && !key_system_previous[q];
10080 4379004 key_system_previous[q] = key_system[q];
10081 4379004 }
10082 208524 }
10083
10084 203804 void update_keys()
10085 {
10086
1/2
✓ Branch 0 taken 203804 times.
✗ Branch 1 not taken.
203804 if (!replay_is_replaying())
10087 poll_keyboard();
10088
10089
2/2
✓ Branch 0 taken 203804 times.
✓ Branch 1 taken 25883108 times.
26086912 for (int32_t q = 0; q < 127; ++q)
10090 {
10091 // When replaying, replay.cpp takes care of updating `key_current_frame`.
10092
1/2
✓ Branch 0 taken 25883108 times.
✗ Branch 1 not taken.
25883108 if (!replay_is_replaying())
10093 key_current_frame[q] = key[q];
10094
10095
2/2
✓ Branch 0 taken 25695539 times.
✓ Branch 1 taken 187569 times.
25883108 KeyPress[q] = key_current_frame[q] && !key_previous_frame[q];
10096
3/4
✓ Branch 0 taken 6674 times.
✓ Branch 1 taken 25876434 times.
✓ Branch 2 taken 6674 times.
✗ Branch 3 not taken.
25883108 if (KeyPress[q] && q == KEY_B) {
10097 int lol = 1;
10098 }
10099 25883108 KeyInput[q] = key_current_frame[q];
10100 25883108 key_previous_frame[q] = key_current_frame[q];
10101 25883108 }
10102 203804 }
10103
10104 bool zc_disablekey(int32_t k, bool val)
10105 {
10106 switch(k)
10107 {
10108 case KEY_F7:
10109 case KEY_F8:
10110 case KEY_F9:
10111 return false;
10112
10113 default:
10114 disabledKeys[k] = val;
10115 return true;
10116 }
10117 }
10118
10119 void zc_putpixel(int32_t layer, int32_t x, int32_t y, int32_t cset, int32_t color, int32_t timer)
10120 {
10121 timer=timer;
10122 particles.add(new particle(zfix(x), zfix(y), layer, cset, color));
10123 }
10124
10125 // these are here so that copy_dialog won't choke when compiling zelda
10126 int32_t d_alltriggerbutton_proc(int32_t, DIALOG*, int32_t)
10127 {
10128 return D_O_K;
10129 }
10130
10131 int32_t d_comboa_radio_proc(int32_t, DIALOG*, int32_t)
10132 {
10133 return D_O_K;
10134 }
10135
10136 int32_t d_comboabutton_proc(int32_t, DIALOG*, int32_t)
10137 {
10138 return D_O_K;
10139 }
10140
10141 int32_t d_ssdn_btn_proc(int32_t, DIALOG*, int32_t)
10142 {
10143 return D_O_K;
10144 }
10145
10146 int32_t d_ssdn_btn2_proc(int32_t, DIALOG*, int32_t)
10147 {
10148 return D_O_K;
10149 }
10150
10151 int32_t d_ssdn_btn3_proc(int32_t, DIALOG*, int32_t)
10152 {
10153 return D_O_K;
10154 }
10155
10156 int32_t d_ssdn_btn4_proc(int32_t, DIALOG*, int32_t)
10157 {
10158 return D_O_K;
10159 }
10160
10161 int32_t d_sslt_btn_proc(int32_t, DIALOG*, int32_t)
10162 {
10163 return D_O_K;
10164 }
10165
10166 int32_t d_sslt_btn2_proc(int32_t, DIALOG*, int32_t)
10167 {
10168 return D_O_K;
10169 }
10170
10171 int32_t d_sslt_btn3_proc(int32_t, DIALOG*, int32_t)
10172 {
10173 return D_O_K;
10174 }
10175
10176 int32_t d_sslt_btn4_proc(int32_t, DIALOG*, int32_t)
10177 {
10178 return D_O_K;
10179 }
10180
10181 int32_t d_ssrt_btn_proc(int32_t, DIALOG*, int32_t)
10182 {
10183 return D_O_K;
10184 }
10185
10186 int32_t d_ssrt_btn2_proc(int32_t, DIALOG*, int32_t)
10187 {
10188 return D_O_K;
10189 }
10190
10191 int32_t d_ssrt_btn3_proc(int32_t, DIALOG*, int32_t)
10192 {
10193 return D_O_K;
10194 }
10195
10196 int32_t d_ssrt_btn4_proc(int32_t, DIALOG*, int32_t)
10197 {
10198 return D_O_K;
10199 }
10200
10201 int32_t d_ssup_btn_proc(int32_t, DIALOG*, int32_t)
10202 {
10203 return D_O_K;
10204 }
10205
10206 int32_t d_ssup_btn2_proc(int32_t, DIALOG*, int32_t)
10207 {
10208 return D_O_K;
10209 }
10210
10211 int32_t d_ssup_btn3_proc(int32_t, DIALOG*, int32_t)
10212 {
10213 return D_O_K;
10214 }
10215
10216 int32_t d_ssup_btn4_proc(int32_t, DIALOG*, int32_t)
10217 {
10218 return D_O_K;
10219 }
10220
10221 int32_t d_tri_edit_proc(int32_t, DIALOG*, int32_t)
10222 {
10223 return D_O_K;
10224 }
10225
10226 int32_t d_triggerbutton_proc(int32_t, DIALOG*, int32_t)
10227 {
10228 return D_O_K;
10229 }
10230
10231 /*** end of zc_sys.cc ***/
10232
10233